Note:Unlike the out of the box security code solution, access and ID tokens require setting up an allow-list on AODocs: GCP client IDs for Google tokens, and Microsoft tenants/applications for Microsoft tokens. This is not currently possible out of the box — contact AODocs support to register them.
- 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.
Google OAuth 2.0 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 a Google 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 a Google 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
Microsoft OAuth 2.0 ID tokens
AODocs accepts Microsoft Entra ID tokens (v1.0 and v2.0) issued for an allow-listed tenant and application. Only ID tokens are supported — Microsoft access tokens are not accepted. A Microsoft token grants AODocs-only access; it cannot be used to reach Google Drive scopes.Note:Your Microsoft tenant (and the application issuing the ID tokens) must be registered with AODocs support before tokens will be accepted.
Obtain a Microsoft ID token
The token must be a JWTid_token issued by Microsoft Entra. Access tokens are not accepted. Refer to Microsoft’s official documentation for the supported acquisition flows:
AODocs requires the client app to request the following OAuth scopes when signing the user in with Microsoft Entra:
openid is mandatory to receive an ID token at all; profile and email ensure the identity claims AODocs needs (notably oid and upn) are populated in the token.
Required claims
AODocs validates and uses the following claims from the Microsoft ID token:| Claim | Required | Used for |
|---|---|---|
iss | yes | Must start with https://login.microsoftonline.com/ or https://sts.windows.net/ |
tid | yes | Validated against the allow-listed tenant |
ver | yes | Must be 1.0 or 2.0 |
oid | yes | Mapped to the AODocs user identifier |
upn | yes | Mapped to the AODocs user email — must be non-empty and match a known AODocs user |
email claim is ignored for identity purposes (Microsoft does not guarantee its verification); identity is taken from upn.
Use a Microsoft ID token
Pass the Microsoft ID token in theAuthorization header with the Bearer scheme, exactly as for Google tokens:
Example request with a Microsoft ID token
Token expiration
All Bearer tokens have a built-in expiration. For Google access tokens, if you requested offline access to token scopes, you can refresh tokens as necessary without having to prompt the user for permission. Microsoft ID tokens (typically valid for one hour) cannot be refreshed by AODocs — the client must obtain a new token from Microsoft Entra when the previous one expires.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 .