Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', '{\n "error": "invalid_grant",\n "error_description": "Bad Request"\n}') #341

Closed
rabeehk opened this issue Dec 13, 2020 · 8 comments
Assignees
Labels
api: storage Issues related to the googleapis/python-storage API. type: question Request for information or clarification. Not an issue.

Comments

@rabeehk
Copy link

rabeehk commented Dec 13, 2020

Hi
I am trying with

import os
from google.cloud import storage
os.environ["GCLOUD_PROJECT"]=project-name
file_path = 'outputs/mixture1/meta-adapter/task-emb/mix1-meta-task-emb-new-lr-3e-03/eval_results.json'
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket-name)

and I get
Traceback (most recent call last):
File "test.py", line 19, in
bucket = storage_client.get_bucket("gs://ruse-xcloud-bucket")
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/cloud/storage/client.py", line 361, in get_bucket
if_metageneration_not_match=if_metageneration_not_match,
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/cloud/storage/bucket.py", line 936, in reload
if_metageneration_not_match=if_metageneration_not_match,
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/cloud/storage/_helpers.py", line 210, in reload
retry=DEFAULT_RETRY,
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/cloud/storage/_http.py", line 63, in api_request
return call()
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/api_core/retry.py", line 286, in retry_wrapped_func
on_error=on_error,
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/api_core/retry.py", line 184, in retry_target
return target()
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/cloud/_http.py", line 434, in api_request
timeout=timeout,
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/cloud/_http.py", line 292, in _make_request
method, url, headers, data, target_object, timeout=timeout
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/cloud/_http.py", line 330, in _do_request
url=url, method=method, headers=headers, data=data, timeout=timeout
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/auth/transport/requests.py", line 460, in request
self.credentials.before_request(auth_request, method, url, request_headers)
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/auth/credentials.py", line 133, in before_request
self.refresh(request)
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/oauth2/credentials.py", line 206, in refresh
self._scopes,
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/oauth2/_client.py", line 248, in refresh_grant
response_data = _token_endpoint_request(request, token_uri, body)
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/oauth2/_client.py", line 124, in _token_endpoint_request
_handle_error_response(response_body)
File "/usr/local/google/home/rabeeh/anaconda3/envs/internship/lib/python3.7/site-packages/google/oauth2/_client.py", line 60, in _handle_error_response
raise exceptions.RefreshError(error_details, response_body)
google.auth.exceptions.RefreshError: ('invalid_grant: Bad Request', '{\n "error": "invalid_grant",\n "error_description": "Bad Request"\n}')

thanks

@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/python-storage API. label Dec 13, 2020
@HemangChothani
Copy link
Contributor

@rabeehk I think this problem is related to credential file.

Please go through the auth documentation to generate the credentials file for login.

OR

Please do the following steps to verify the login with gcloud:

  • gcloud auth revoke

  • gcloud auth login

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Dec 14, 2020
@HemangChothani HemangChothani added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. labels Dec 16, 2020
@frankyn frankyn self-assigned this Feb 3, 2021
@frankyn
Copy link
Member

frankyn commented Feb 3, 2021

Hi @rabeehk,

Thanks for filing the issue.
This is a duplicate of #17, which is being looked at here: googleapis/google-auth-library-python#261

@frankyn frankyn closed this as completed Feb 3, 2021
@frankyn frankyn added status: duplicate Duplicate. and removed type: question Request for information or clarification. Not an issue. labels Feb 3, 2021
@frankyn frankyn reopened this Feb 3, 2021
@frankyn frankyn added priority: p2 Moderately-important priority. Fix may not be included in next release. status: investigating The issue is under investigation, which is determined to be non-trivial. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. type: question Request for information or clarification. Not an issue. and removed status: duplicate Duplicate. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Feb 3, 2021
@frankyn
Copy link
Member

frankyn commented Feb 3, 2021

Hi @rabeehk,

Are you still experiencing this issue?

@frankyn frankyn assigned tritone and unassigned frankyn Feb 8, 2021
@polmonta
Copy link

I am getting the same error with the Google Calendar API @frankyn

@tritone tritone assigned andrewsg and tritone and unassigned tritone and andrewsg Feb 22, 2021
@tritone
Copy link
Contributor

tritone commented Feb 22, 2021

Closing due to lack of response and open duplicate issues #17 and googleapis/google-auth-library-python#261

@polmv123 this library does not cover the calendar API.

@tritone tritone closed this as completed Feb 22, 2021
@tarikwaleed
Copy link

using Service acount will prevent this from happening ?

@e-compagno
Copy link

Hi, I had the same issue and I've fixed it by running

gcloud auth application-default login

@ukpratik
Copy link

ukpratik commented Apr 4, 2024

I am too getting similar following issue, while using GCS on local, although working fine when running from the online google console or when when I deploy the service:

raise exceptions.RefreshError(
google.auth.exceptions.RefreshError: ('invalid_grant: Invalid grant: account not found', {'error': 'invalid_grant', 'error_description': 'Invalid grant: account not found'})

I already did the gcloud auth application-default login, and authenticated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/python-storage API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

10 participants