Consistent authError with message Active session is invalid. Error code: 4

I am calling Google Drive API files.list to enumerate a user’s My Drive files using a service account with user impersonation. Using files.list (Method: files.list  |  Google Drive  |  Google for Developers) from the v3 Google Drive API.
For most of the users, the API is returning the accurate list of files in their drive. However, for a handful of users, we are consistently seeing the following error :
{
“error”: {
“code”: 401,
“message”: “The caller does not have permission”,
“errors”: [
{
“message”: “Active session is invalid. Error code: 4”,
“domain”: “global”,
“reason”: “authError”,
“location”: “Authorization”,
“locationType”: “header”
}
],
“status”: “PERMISSION_DENIED”
}
}

Not seeing any insights on this specific error in the error handling documentation ( Resolve errors  |  Google Drive  |  Google for Developers ).

Unable to understand why a user’s own MyDrive returns “The caller does not have permission”. Any insights on why this is happening and how to fix this would be helpful.

1 Like