Google token request fails with unauthorized_client
unauthorized_clientShort answer
For a service account using domain-wide delegation, unauthorized_client means Google Workspace has not approved that client and those scopes. Authorize the service account's numeric client ID with the exact scopes in the Admin console, and never add it by email address or through a group.
Fix it fast
1Find out which cause you have
Read the error_description in the response. The two texts below point to different causes.
# look at the JSON body of the failed token request: error and error_description2Match what you see, then jump to its fix
What does the error look like?
unauthorized_clientUnauthorized client or scope in requestClient is unauthorized to retrieve access tokens using this method
Cause 1 of 2
The service account is not authorized for the user and scopes in the Admin console
1Check
This appears when you use domain-wide delegation and the service account is not authorized for the user named in the sub claim. Open the Domain-wide delegation page in the Admin console and look for the client ID and scopes.
# Admin console: Security > API controls > Domain-wide delegation2Fix
Add the service account's client ID with exactly the scopes your code requests, then wait. Changes can take a few minutes and up to 24 hours.
# Admin console: Add new, enter Client ID and the OAuth scopes (comma-separated)3Verify
Request a token again for that sub user.
# the token response contains access_token, not errorConfirmed by developers.google.com
Cause 2 of 2
The client was added by email address or as a group
1Check
Google says this happens when the service account was added in the Admin console by its email address instead of its numeric client ID, or when a Google Group was used.
# compare the Admin console entry with the service account's numeric client ID2Fix
Remove the entry and add it again with the numeric ID. If a group was used, replace it with the individual service or user account.
# Admin console: delete the entry, then add the numeric Client ID again3Verify
Request the token again.
# no unauthorized_client in the responseConfirmed by developers.google.com
How do I stop it coming back?
- Keep a record of each service account's numeric client ID and the exact scopes it needs.
- Add scopes in the Admin console in the same step you add them in code.
- Allow up to a day for delegation changes before you start debugging.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Related fixes
Security
Entra ID token request fails: the request body must contain the parameter 'grant_type'
AADSTS900144: The request body must contain the following parameter: 'grant_type'.
The token endpoint did not find grant_type in the form body of your POST.
3 causes, each with a fixSecurity
Angular HttpClient does not add the X-XSRF-TOKEN header to a request
403 Forbidden on POST, PUT or DELETE while GET works
Angular copies the XSRF-TOKEN cookie into an X-XSRF-TOKEN header only for mutating requests to the same origin, and only when the cookie is readable by script.
5 causes, each with a fixSecurity
An [Authorize] endpoint rejects a request with a bearer token
Authorization Header sent: no Bearer token sent.
An [Authorize] endpoint without a policy name requires an authenticated user.
4 causes, each with a fixSecurity
ASP.NET Core API rejects an Angular user's token: the signature key was not found
401 Unauthorized
The API looked for the key named by the token's kid in the key set it downloaded from your Authority, and the key was not there.
4 causes, each with a fixSecurity
ASP.NET Core rejects the token before checking it: IDX12741, three segments expected
401 Unauthorized
IDX12741 means the string the API pulled out of the Authorization header is not shaped like a JWT: a signed token has three dot-separated parts and an encrypted one has five.
3 causes, each with a fixSecurity
A Microsoft Entra access token shows Invalid Signature when you check it yourself
Tokens that a Microsoft API receives might not always be a JWT that can be decoded
A token issued for Microsoft Graph is not meant for you to validate, so a failed signature check is expected.
2 causes, each with a fix