Class AppIdentityCredential (1.35.2)

public class AppIdentityCredential implements HttpRequestInitializer, HttpExecuteInterceptor

OAuth 2.0 credential in which a client Google App Engine application needs to access data that it owns, based on <a href="https://developers.google.com/appengine/docs/java/appidentity/

Java_Asserting_identity_to_Google_APIs">Asserting Identity to Google APIs

Intercepts the request by using the access token obtained from AppIdentityService#getAccessToken(Iterable).

Sample usage:


 public static HttpRequestFactory createRequestFactory(HttpTransport transport,
     JsonFactory jsonFactory, TokenResponse tokenResponse) {
   return transport.createRequestFactory(
   new AppIdentityCredential("https://www.googleapis.com/auth/urlshortener"));
 }
 

Implementation is immutable and thread-safe.

Inheritance

java.lang.Object > AppIdentityCredential

Implements

com.google.api.client.http.HttpRequestInitializer, com.google.api.client.http.HttpExecuteInterceptor

Constructors

AppIdentityCredential(AppIdentityCredential.Builder builder)

protected AppIdentityCredential(AppIdentityCredential.Builder builder)
Parameter
NameDescription
builderAppIdentityCredential.Builder

builder

AppIdentityCredential(Collection<String> scopes)

public AppIdentityCredential(Collection<String> scopes)
Parameter
NameDescription
scopesCollection<String>

OAuth scopes

Methods

getAppIdentityService()

public final AppIdentityService getAppIdentityService()

Gets the App Identity Service that provides the access token.

Returns
TypeDescription
com.google.appengine.api.appidentity.AppIdentityService

getScopes()

public final Collection<String> getScopes()

Gets the OAuth scopes (unmodifiable).

Returns
TypeDescription
Collection<String>

initialize(HttpRequest request)

public void initialize(HttpRequest request)
Parameter
NameDescription
requestcom.google.api.client.http.HttpRequest
Exceptions
TypeDescription
IOException

intercept(HttpRequest request)

public void intercept(HttpRequest request)
Parameter
NameDescription
requestcom.google.api.client.http.HttpRequest
Exceptions
TypeDescription
IOException