Skip to content

Commit

Permalink
Merge pull request #29 from LinaKK/ref/be/product
Browse files Browse the repository at this point in the history
Fix: update field initialization in [OAuth2Controller]
  • Loading branch information
LinaKK authored Jan 19, 2025
2 parents f230f96 + c3c1006 commit 3cb5177
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions server/src/main/java/greenNare/auth/oauth2/OAuth2Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import java.util.List;

@RestController
Expand All @@ -25,17 +26,25 @@ public class OAuth2Controller {
@Value("${spring.security.oauth2.client.registration.google.scope}")
private List<String> scope;

private String scopeString = String.join(" ", scope);
private String scopeString;

@PostConstruct
public void init(){
scopeString = String.join("%20", scope);
System.out.println(scopeString);
}


private final String endPoint = "https://accounts.google.com/o/oauth2/auth";


@GetMapping("/google")
public ResponseEntity getGoogleOAuth2EndPoint(){
String authUrl = endPoint +
"?client_id=" + clientId +
"&redirect_uri=" + redirectUri +
"&response_type=code" +
"&scope=" + scopeString +
"&scope=" + scope +
"&access_type=offline";

SingleResponseDto responseDto = new SingleResponseDto(authUrl);
Expand Down

0 comments on commit 3cb5177

Please sign in to comment.