2
Google gaelyk 앱 중 하나에 google-start-project 코드를 사용하고 있습니다. OAuth 2.0 인증 프로세스에 대한 그루비 코드입니다. 트위터와 달리 앱이 승인을 요청할 때마다 사용자는 앱을 계속 허용해야하며 이상하다고 생각합니다. 내가 만든 실수가 있니?OAuth 및 google plus api
// Check for an error returned by OAuth
if (params.error) {
response.setContentType("text/plain");
out.println("There was a problem during authentication: " + error);
log.severe("There was a problem during authentication: " + error);
return;
}
// When we're redirected back from the OAuth 2.0 grant page, a code will be supplied in a GET parameter named 'code'
if (!params.code) {
// Now that we have the OAuth 2.0 code, we must exchange it for a token to make API requests.
// Build the authorization URL
AuthorizationRequestUrl authorizeUrl = new GoogleAuthorizationRequestUrl(
CLIENT_ID,
REDIRECT_URI,
SCOPES
);
authorizeUrl.redirectUri = REDIRECT_URI;
authorizeUrl.scope = SCOPES;
String authorizationUrl = authorizeUrl.build();
log.info("Redirecting browser for OAuth 2.0 authorization to " + authorizationUrl);
response.sendRedirect(authorizationUrl);
return;
} else {
log.info("Exchanging OAuth code for access token using server side call");
AccessTokenResponse accessTokenResponse = new GoogleAccessTokenRequest.GoogleAuthorizationCodeGrant(
new NetHttpTransport(),
new GsonFactory(),
CLIENT_ID,
CLIENT_SECRET,
params.code,
REDIRECT_URI
).execute();
log.info("Storing authentication token into the session");
request.session.accessToken = accessTokenResponse.accessToken
request.session.refreshToken = accessTokenResponse.refreshToken
//The authentication is all done! Redirect back to the samples index so you can play with them.
response.sendRedirect("/");
}
redirect_uri의 가치는 무엇입니까? 여기서 문제가 생겼어. –