I've been getting an Authentication error every time I make an HTTP request via Python.
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. 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": "Login Required.",
"domain": "global",
"reason": "required",
"location": "Authorization",
"locationType": "header"
}
],
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CREDENTIALS_MISSING",
"domain": "googleapis.com",
"metadata": {
"method": "ccc.hosted.frontend.directory.v1.DirectoryTokens.Get",
"service": "admin.googleapis.com"
}
}
]
}
}
This is 1 of 2 results I've gotten, both deal with this exact phrase:
Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential.
Here is the current code:
import requests
userKey = "(My User Key from the Google Cloud Service Account)"
clientId = "(From my OAuth 2.0 Client IDs)"
url = f"https://admin.googleapis.com/admin/directory/v1/users/{userKey}/tokens/{clientId}"
r = requests.get(url)
print(r.text)
This outputs the error above.
There have been multiple URI's used in the OAuth 2.0 Client IDs but this doesn't seem to solve the issue.
If anyone has any clue, help would be greatly appreciated.