App Engine-specific helpers make quick work of authenticated calls to APIs, and you do not need to worry about exchanging code for tokens.
For example:
@Override
protected
void
doGet
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
IOException
{
AppIdentityCredential
credential
=
new
AppIdentityCredential
(
Arrays
.
asList
(
UrlshortenerScopes
.
URLSHORTENER
));
Urlshortener
shortener
=
new
Urlshortener
.
Builder
(
new
UrlFetchTransport
(),
new
JacksonFactory
(),
credential
)
.
build
();
UrlHistory
history
=
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. The helpers aim to:
AuthorizationCodeFlow
).PersistenceCapable
.