Package com.google.api.client.auth.oauth2
Implementation of the OAuth 2.0 Authorization
Framework.
Before using this library, you will typically need to register your application with the authorization server to receive a client ID and client secret. See Client Registration.
These are the typical steps of the web server flow based on an authorization code, as specified in Authorization Code Grant:
- Redirect the end user in the browser to the authorization page using
AuthorizationCodeRequestUrl
to grant your application access to the end user's protected data. - Process the authorization response using
AuthorizationCodeResponseUrl
to parse the authorization code. - Request an access token and possibly a refresh token using
AuthorizationCodeTokenRequest
. - Access protected resources using
Credential
. Expired access tokens will automatically be refreshed using the refresh token (if applicable).
These are the typical steps of the the browser-based client flow specified in Implicit Grant:
- Redirect the end user in the browser to the authorization page using
BrowserClientRequestUrl
to grant your browser application access to the end user's protected data. - Use a JavaScript application to process the access token found in the URL fragment at the redirect URI registered with the authorization server.
- Since:
- 1.7
- Author:
- Yaniv Inbar
-
Interface Summary Interface Description AuthorizationCodeFlow.CredentialCreatedListener Listener for a created credential after a successful token response inAuthorizationCodeFlow.createAndStoreCredential(com.google.api.client.auth.oauth2.TokenResponse, java.lang.String)
.Credential.AccessMethod Method of presenting the access token to the resource server as specified in Accessing Protected Resources.CredentialRefreshListener Listener for refresh token results.CredentialStore Deprecated. (to be removed in the future) UseDataStoreFactory
withStoredCredential
instead. -
Class Summary Class Description AuthorizationCodeFlow Thread-safe OAuth 2.0 authorization code flow that manages and persists end-user credentials.AuthorizationCodeFlow.Builder Authorization code flow builder.AuthorizationCodeRequestUrl OAuth 2.0 URL builder for an authorization web page to allow the end user to authorize the application to access their protected resources and that returns an authorization code, as specified in Authorization Code Grant.AuthorizationCodeResponseUrl OAuth 2.0 URL parser for the redirect URL after end user grants or denies authorization as specified in Authorization Response.AuthorizationCodeTokenRequest OAuth 2.0 request for an access token using an authorization code as specified in Access Token Request.AuthorizationRequestUrl OAuth 2.0 URL builder for an authorization web page to allow the end user to authorize the application to access their protected resources, as specified in Authorization Endpoint.BearerToken OAuth 2.0 helper for accessing protected resources using the Bearer Token specification.BrowserClientRequestUrl OAuth 2.0 URL builder for an authorization web page to allow the end user to authorize the application to access their protected resources and that returns the access token to a browser client using a scripting language such as JavaScript, as specified in Implicit Grant.ClientCredentialsTokenRequest OAuth 2.0 request for an access token using only its client credentials as specified in Client Credentials Grant.ClientParametersAuthentication Client credentials specified as URL-encoded parameters in the HTTP request body as specified in Client PasswordCredential Thread-safe OAuth 2.0 helper for accessing protected resources using an access token, as well as optionally refreshing the access token when it expires using a refresh token.Credential.Builder Credential builder.CredentialStoreRefreshListener Deprecated. (to be removed in the future) UseDataStoreCredentialRefreshListener
instead.DataStoreCredentialRefreshListener Beta
Thread-safe OAuth 2.0 credential refresh listener that stores the refresh token response in the credential data store.PasswordTokenRequest OAuth 2.0 request for an access token using the user's username and password as specified in Resource Owner Password Credentials Grant.RefreshTokenRequest OAuth 2.0 request to refresh an access token using a refresh token as specified in Refreshing an Access Token.StoredCredential Beta
Credential information to be stored in aDataStoreFactory
.TokenErrorResponse OAuth 2.0 parser for an error access token response as specified in Error Response.TokenRequest OAuth 2.0 request for an access token as specified in Obtaining Authorization.TokenResponse OAuth 2.0 JSON model for a successful access token response as specified in Successful Response. -
Exception Summary Exception Description TokenResponseException Exception thrown when receiving an error response from the token server as specified in Error Response