AuthorizationClient
Stay organized with collections
Save and categorize content based on your preferences.
A client for the authorization API.
Public Methods
Requests authorization to access the Google data associated with a signed-in account
on the device.
If an eligible signed-in account is found for the application, this request will
verify that all the requested OAuth 2.0 scopes were previously granted by the user. If
they were, the requested tokens will be returned in the result. If, however, no saved
account is found or the required grants do not exist, the result will contain a
PendingIntent
that can be used to launch the authorization flow. During that flow, the user will be
asked to select an account and/or grant the permission for all or a subset of requested
scopes. An exception will be set on the returned Task
if
authorization is not available on the device (for example, internal error or Play
Services not available).
Parameters
request |
configuration for the authorization operation. |
Returns
Task
which
contains the result of the operation.
public abstract Task<Void> clearToken (ClearTokenRequest
request)
Clears an access token from the local cache.
Parameters
request |
configuration for the clear token operation. |
Returns
- A Task that may be used to check for failure, success or completion
Revokes access given to the current application. Future sign-in or authorization
attempts will require the user to re-consent to all requested scopes. Applications are
required to provide users that are signed in with Google the ability to disconnect
their Google account from the app. If the user deletes their account, you must delete
the information that your app obtained from the Google APIs.
Parameters
request |
configuration for the revoke authorization operation. |
Returns
- A Task that may be used to check for failure, success or completion
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-23 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-23 UTC."],[[["\u003cp\u003e\u003ccode\u003eAuthorizationClient\u003c/code\u003e provides methods for authorizing access to Google data associated with a signed-in account.\u003c/p\u003e\n"],["\u003cp\u003eIt allows requesting authorization and retrieving authorization results.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eauthorize()\u003c/code\u003e initiates the authorization process, potentially launching a flow for user consent if needed.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetAuthorizationResultFromIntent()\u003c/code\u003e extracts the authorization result from the intent returned after a successful authorization.\u003c/p\u003e\n"]]],[],null,["# AuthorizationClient\n\npublic interface **AuthorizationClient** implements [HasApiKey](/android/reference/com/google/android/gms/common/api/HasApiKey)\\\u003c[AuthorizationOptions](/android/reference/com/google/android/gms/auth/api/identity/AuthorizationOptions)\\\u003e \nA client for the authorization API. \n\n### Public Method Summary\n\n|-------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract Task\\\u003c[AuthorizationResult](/android/reference/com/google/android/gms/auth/api/identity/AuthorizationResult)\\\u003e | [authorize](/android/reference/com/google/android/gms/auth/api/identity/AuthorizationClient#authorize(com.google.android.gms.auth.api.identity.AuthorizationRequest))([AuthorizationRequest](/android/reference/com/google/android/gms/auth/api/identity/AuthorizationRequest) request) Requests authorization to access the Google data associated with a signed-in account on the device. |\n| abstract Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [clearToken](/android/reference/com/google/android/gms/auth/api/identity/AuthorizationClient#clearToken(com.google.android.gms.auth.api.identity.ClearTokenRequest))([ClearTokenRequest](/android/reference/com/google/android/gms/auth/api/identity/ClearTokenRequest) request) Clears an access token from the local cache. |\n| abstract [AuthorizationResult](/android/reference/com/google/android/gms/auth/api/identity/AuthorizationResult) | [getAuthorizationResultFromIntent](/android/reference/com/google/android/gms/auth/api/identity/AuthorizationClient#getAuthorizationResultFromIntent(android.content.Intent))([Intent](//developer.android.com/reference/android/content/Intent.html) data) Retrieves the [AuthorizationResult](/android/reference/com/google/android/gms/auth/api/identity/AuthorizationResult) from the [Intent](//developer.android.com/reference/android/content/Intent.html) returned upon successful authorization, throwing an [ApiException](/android/reference/com/google/android/gms/common/api/ApiException) if no result is present or authorization has failed. |\n| abstract Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [revokeAccess](/android/reference/com/google/android/gms/auth/api/identity/AuthorizationClient#revokeAccess(com.google.android.gms.auth.api.identity.RevokeAccessRequest))([RevokeAccessRequest](/android/reference/com/google/android/gms/auth/api/identity/RevokeAccessRequest) request) Revokes access given to the current application. |\n\nPublic Methods\n--------------\n\n#### public abstract Task\\\u003c[AuthorizationResult](/android/reference/com/google/android/gms/auth/api/identity/AuthorizationResult)\\\u003e\n**authorize** ([AuthorizationRequest](/android/reference/com/google/android/gms/auth/api/identity/AuthorizationRequest) request)\n\nRequests authorization to access the Google data associated with a signed-in account\non the device.\n\nIf an eligible signed-in account is found for the application, this request will\nverify that all the requested OAuth 2.0 scopes were previously granted by the user. If\nthey were, the requested tokens will be returned in the result. If, however, no saved\naccount is found or the required grants do not exist, the result will contain a\n[PendingIntent](//developer.android.com/reference/android/app/PendingIntent.html)\nthat can be used to launch the authorization flow. During that flow, the user will be\nasked to select an account and/or grant the permission for all or a subset of requested\nscopes. An exception will be set on the returned [Task](/android/reference/com/google/android/gms/tasks/Task) if\nauthorization is not available on the device (for example, internal error or Play\nServices not available). \n\n##### Parameters\n\n| request | configuration for the authorization operation. |\n|---------|------------------------------------------------|\n\n##### Returns\n\n- [Task](/android/reference/com/google/android/gms/tasks/Task) which contains the result of the operation. \n\n#### public abstract Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **clearToken** ([ClearTokenRequest](/android/reference/com/google/android/gms/auth/api/identity/ClearTokenRequest) request)\n\nClears an access token from the local cache. \n\n##### Parameters\n\n| request | configuration for the clear token operation. |\n|---------|----------------------------------------------|\n\n##### Returns\n\n- A Task that may be used to check for failure, success or completion \n\n#### public abstract [AuthorizationResult](/android/reference/com/google/android/gms/auth/api/identity/AuthorizationResult)\n**getAuthorizationResultFromIntent** ([Intent](//developer.android.com/reference/android/content/Intent.html) data)\n\nRetrieves the [AuthorizationResult](/android/reference/com/google/android/gms/auth/api/identity/AuthorizationResult)\nfrom the [Intent](//developer.android.com/reference/android/content/Intent.html)\nreturned upon successful authorization, throwing an [ApiException](/android/reference/com/google/android/gms/common/api/ApiException)\nif no result is present or authorization has failed. \n\n##### Throws\n\n| [ApiException](/android/reference/com/google/android/gms/common/api/ApiException) | |\n|-----------------------------------------------------------------------------------|---|\n\n#### public abstract Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **revokeAccess** ([RevokeAccessRequest](/android/reference/com/google/android/gms/auth/api/identity/RevokeAccessRequest) request)\n\nRevokes access given to the current application. Future sign-in or authorization\nattempts will require the user to re-consent to all requested scopes. Applications are\nrequired to provide users that are signed in with Google the ability to disconnect\ntheir Google account from the app. If the user deletes their account, you must delete\nthe information that your app obtained from the Google APIs. \n\n##### Parameters\n\n| request | configuration for the revoke authorization operation. |\n|---------|-------------------------------------------------------|\n\n##### Returns\n\n- A Task that may be used to check for failure, success or completion"]]