I'm trying to see if an email account with name@domain.com
already exists but I keep getting this error:
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/admin/directory/v1/users/name%domain.comL?alt=json returned "Not Authorized to access this resource/api">
Although I successfully use the users().insert() method from my code with the same credentials. I've tried the "Try it" webpage for this exact request and noticed two things.
- It worked with the same scopes I'm using (listed below)
- The GET URL they are providing is
https://www.googleapis.com/admin/directory/v1/users/name%40domain.com?key={YOUR_API_KEY}
and nothttps://www.googleapis.com/admin/directory/v1/users/name%domain.comL?alt=json
. I'm just guessing this is just using the OAuth generated key right in the URL.
I'm writing in Python and use google api for python https://github.com/google/google-api-python-client/tree/master/googleapiclient.
The scopes that I'm using:
'https://www.googleapis.com/auth/admin.directory.user',
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/spreadsheets'