Closed tensor17 closed 3 years ago
Note, if this is a usage question, please ask a question in stackoverflow with pygsheets tag.
pygsheets
Describe the bug
12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/pygsheets/client.py", line 161, in open_by_key 12:26:19 | | | includeGridData=False) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/pygsheets/sheet.py", line 164, in get 12:26:19 | | | return self._execute_requests(self.service.spreadsheets().get(spreadsheetId=spreadsheet_id, kwargs)) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/pygsheets/sheet.py", line 495, in _execute_requests 12:26:19 | | | response = request.execute(num_retries=self.retries) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper 12:26:19 | | | return wrapped(*args, *kwargs) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/googleapiclient/http.py", line 929, in execute 12:26:19 | | | headers=self.headers, 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/googleapiclient/http.py", line 191, in _retry_request 12:26:19 | | | resp, content = http.request(uri, method, args, kwargs) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/google_auth_httplib2.py", line 209, in request 12:26:19 | | | self.credentials.before_request(self._request, method, uri, request_headers) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/google/auth/credentials.py", line 133, in before_request 12:26:19 | | | self.refresh(request) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/google/oauth2/service_account.py", line 409, in refresh 12:26:19 | | | request, self._token_uri, assertion 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/google/oauth2/_client.py", line 193, in jwt_grant 12:26:19 | | | response_data = _token_endpoint_request(request, token_uri, body) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/google/oauth2/_client.py", line 165, in _token_endpoint_request 12:26:19 | | | _handle_error_response(response_data) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/google/oauth2/_client.py", line 60, in _handle_error_response 12:26:19 | | | raise exceptions.RefreshError(error_details, response_data) 12:26:19 | | | google.auth.exceptions.RefreshError: ('invalid_grant: Invalid JWT: Failed audience check. The right audience is https://accounts.google.com/o/oauth2/token', {'error': 'invalid_grant', 'error_description': 'Invalid JWT: Failed audience check. The right audience is https://accounts.google.com/o/oauth2/token'})
To Reproduce Steps to reproduce the behavior:
code here ... gc = pygsheets.authorize(custom_credentials=credentials) gc.open_by_key(spreadsheet_id)
System Information
fixed it - the issue was on the google service account creds json file I was using
Note, if this is a usage question, please ask a question in stackoverflow with
pygsheets
tag.Describe the bug
When authenticating using google sheets service account credentials I'm facing the following error:
12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/pygsheets/client.py", line 161, in open_by_key 12:26:19 | | | includeGridData=False) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/pygsheets/sheet.py", line 164, in get 12:26:19 | | | return self._execute_requests(self.service.spreadsheets().get(spreadsheetId=spreadsheet_id, kwargs)) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/pygsheets/sheet.py", line 495, in _execute_requests 12:26:19 | | | response = request.execute(num_retries=self.retries) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper 12:26:19 | | | return wrapped(*args, *kwargs) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/googleapiclient/http.py", line 929, in execute 12:26:19 | | | headers=self.headers, 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/googleapiclient/http.py", line 191, in _retry_request 12:26:19 | | | resp, content = http.request(uri, method, args, kwargs) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/google_auth_httplib2.py", line 209, in request 12:26:19 | | | self.credentials.before_request(self._request, method, uri, request_headers) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/google/auth/credentials.py", line 133, in before_request 12:26:19 | | | self.refresh(request) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/google/oauth2/service_account.py", line 409, in refresh 12:26:19 | | | request, self._token_uri, assertion 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/google/oauth2/_client.py", line 193, in jwt_grant 12:26:19 | | | response_data = _token_endpoint_request(request, token_uri, body) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/google/oauth2/_client.py", line 165, in _token_endpoint_request 12:26:19 | | | _handle_error_response(response_data) 12:26:19 | | | File "/usr/local/lib/python3.6/dist-packages/google/oauth2/_client.py", line 60, in _handle_error_response 12:26:19 | | | raise exceptions.RefreshError(error_details, response_data) 12:26:19 | | | google.auth.exceptions.RefreshError: ('invalid_grant: Invalid JWT: Failed audience check. The right audience is https://accounts.google.com/o/oauth2/token', {'error': 'invalid_grant', 'error_description': 'Invalid JWT: Failed audience check. The right audience is https://accounts.google.com/o/oauth2/token'})
To Reproduce Steps to reproduce the behavior:
System Information