App Engine-specific helpers make quick work of authenticated calls to APIs, andyou do not need to worry about exchanging code for tokens.
For example:
@OverrideprotectedvoiddoGet(HttpServletRequestreq,HttpServletResponseresp)throwsIOException{AppIdentityCredentialcredential=newAppIdentityCredential(Arrays.asList(UrlshortenerScopes.URLSHORTENER));Urlshortenershortener=newUrlshortener.Builder(newUrlFetchTransport(),newJacksonFactory(),credential).build();UrlHistoryhistory=shortener.URL().list().execute();...}
If you are building a web app that interacts with a user’s data via an OAuth 2.0-enabled API, we’ve created some helpers to assist you with the process. Thehelpers aim to:
AuthorizationCodeFlow
).PersistenceCapable
.