Note:Unlike the out of the box security code solution, access and ID tokens require setting up a process on AODocs to whitelist client IDs. This is not currently possible out of the box.
- JWT ID Tokens: these tokens only convey the identity of the user, and are encoded strings in the JWT format
- OAuth 2.0 Access Token: these tokens have authorization scopes associated with them, and can provide access to Google API resources, like Drive, Gmail, etc.
AODocs API authentication flow
When a client app gets the user to authenticate, Google can generate two types of tokens:- an ID token (JWT) without any authorization scope (conveys only identity);
- an access token with a set of scopes (AODocs requires at least the email address visibility scope — https://www.googleapis.com/auth/userinfo.email — to authorize a user to perform any operation)
Get an access or ID token
There are many ways of obtaining an OAuth 2.0 token. Describing all the use cases is beyond the scope of this article. You can read more about Google’s approach on the following Google documentation pages:- Setting up OAuth 2.0 - API Console Help
- Using OAuth 2.0 to Access Google APIs | Google Identity Platform
- OAuth 2.0 for Client-side Web Applications | Google Identity Platform
- Using OAuth 2.0 for Web Server Applications | Google Identity Platform
Use access or ID token
When you receive tokens from Google, they should look something along the lines of the following.Sample tokens from Google
Note:Access tokens usually start with the string
ya29., and because they’re opaque (not actual data but pointers to data elsewhere), they’re usually shorter than ID tokens. The latter are longer because they contain actual data, encoded into three pieces: header, claims, and signature.- access token for AODocs and Drive
- ID token for just AODocs
Authorization HTTP header’s Bearer value:
Example request with token as header parameter
Token expiration
All Bearer tokens have a built-in expiration. If you requested offline access to token scopes, you can refresh tokens as necessary without having to prompt the user for permission.Authentication errors with access/ID tokens
Token errors occur only when the token is:- missing
- incorrect
- expired
401: Unauthorized as listed in HTTP status codes and error scenarios.
To create, manage, and troubleshoot your tokens, see the Google Developers OAuth 2.0 Playground .