I am trying to use this API call - https://developers.google.com/gmail/api/reference/rest/v1/users.settings.delegates/list
To list the delegates of users in Gmail.
I have created a Service Account, given it Domain Wide delegation, and created a js script to generate a JWT and access token.
The service account has the right scopes and everything, but…i’m still stuck. The error i’m getting is
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"errors": [
{
"message": "Invalid Credentials",
"domain": "global",
"reason": "authError",
"location": "Authorization",
"locationType": "header"
}
],
"status": "UNAUTHENTICATED"
}
}
Does anyone have any experience in working with this delegate endpoint, and using a Service Account, as i’m pulling my hair out.
I know the access token only lasts 1hour (3600 secs).
The script i’m using to generate the JWT seems OK
So, any assistance would be appreciated.