I am attempting to use the Gmail API to import messages to a user. https://developers.google.com/gmail/api/v1/reference/users/messages/import
I can do this successfully for most users using the following request. The bearer token is generated using a service account p12 certificate/key file. The scopes listed in the documentation have been setup.
POST https://www.googleapis.com/upload/gmail/v1/users/[email protected]/messages/import?uploadType=multipart&deleted=true HTTP/1.1
Authorization: Bearer ya29.mytoken
{"labelIds":[]}
However, when I try to use this endpoint for a user flagged as archived, then I receive the following response.
HTTP/1.1 403 Forbidden
{
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"errors": [
{
"message": "The request is missing a valid API key.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}
Is it possible to import messages to an archived user? Are there additional steps needed to authenticate this request?