间歇性地收到此错误
请求https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest时的 HttpError 403返回“调用者没有权限”
它有时有效,有时无效。我在 oauth2 操场上看到了同样的问题
这是我的代码 -
googlecredentials = GoogleCredentials(
access_token=None,
client_id='xxx',
client_secret='xxxx',
refresh_token='xxxx',
token_expiry=None,
token_uri="https://www.googleapis.com/oauth2/v3/token",
user_agent='Python client library'
)
service = build('gmail', 'v1', credentials=googlecredentials)
results = service.users().labels().list(userId='me').execute()
labels = results.get('labels', [])
response = service.users().messages().list(userId='me', q='subject:FDA').execute()
print(response)