Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Credential credential = new Credential.Builder(BearerToken.authorizationHeaderAccessMethod())
- .addRefreshListener(new CredentialStoreRefreshListener(stripesActionBeanContext.getUser().getUserId(),
- new AppEngineCredentialStore()))
- .setJsonFactory(new JacksonFactory())
- .setTokenServerUrl(new GenericUrl("https://accounts.google.com/o/oauth2/token"))
- .setClientAuthentication(
- new ClientParametersAuthentication(
- Constants.GOOGLE_API_KEY,
- Constants.GOOGLE_API_SECRET))
- .setTransport(new UrlFetchTransport())
- .build();
- AppEngineCredentialStore appEngineCredentialStore =
- new AppEngineCredentialStore();
- if (! appEngineCredentialStore.load(stripesActionBeanContext.getUser().getUserId(), credential)) {
- log.debug("calling AuthorizationCodeRequestUrl");
- String url =
- new AuthorizationCodeRequestUrl("https://accounts.google.com/o/oauth2/auth",
- Constants.GOOGLE_API_KEY)
- .setRedirectUri(Constants
- .googleOJCCallbackUri(stripesActionBeanContext.getRequest().getScheme(),
- stripesActionBeanContext.getRequest().getServerName(),
- stripesActionBeanContext.getRequest().getServerPort()))
- .setScopes(Collections.singletonList("https://www.googleapis.com/auth/urlshortener"))
- .setState(stripesActionBeanContext.getRequest().getRequestURI())
- .set("approval_prompt", "force")
- .set("access_type", "offline")
- .build();
- log.debug("redirect url: {}", url);
- return (new RedirectResolution(url));
- }
Add Comment
Please, Sign In to add comment