| title | Running on Google App Engine |
|---|
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:
- Simplify the process of obtaining access tokens
(
AuthorizationCodeFlow). - Manage tokens, after they are obtained, by marking them as
PersistenceCapable. - Simplify the process of making authenticated calls using the access token's credential.
- Insulate you from the details of authentication when writing servlets.
- Install the Google API Client Library for Java:
- Follow the download instructions and put the library jar files into your war/WEB-INF/lib directory.
- Alternatively, you can use Maven.
- Learn about using OAuth 2.0 with the authorization code flow for Google App Engine applications.
- Learn about using OAuth 2.0 with the Google App Engine Identity API.
- Take a look at the Calendar App Engine sample. This sample combines our Java library and auth helpers to show you how to access end-user data from within a Google App Engine web app. The sample also uses GWT for the user interface.