I am unable to authenticate properly using the following command
gcloud auth application-default login --impersonate-service-account=<sa_email>
The user I am authenticating with has the Service Account Token Creator role.
However, when executing this code, I receive the following error. I think I have done everything correctly. I don't understand what I'm doing wrong.
import google.auth
from googleapiclient.discovery import build
creds, _ = google.auth.default(scopes=['https://www.googleapis.com/auth/spreadsheets'])
service = build('sheets', 'v4', credentials=creds)
result = service.spreadsheets().values().get(
spreadsheetId=<spreadsheet_id>, range=<range_name>).execute()
\lib\site-packages\google\auth\impersonated_credentials.py", line 103, in _make_iam_token_request raise exceptions.RefreshError(_REFRESH_ERROR, response_body) google.auth.exceptions.RefreshError: ('Unable to acquire impersonated credentials', '')
Thank you very much for your help.
p.s. iamcredentials.googleapis.com is enabled.