googleapis/google-auth-library-python-oauthlib

Mismatch in credentials.json keys and that expected by this library.

Closed this issue · 3 comments

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

  • OS type and version: WSL running Windows 11 (I think WSL 2)
  • Python version: python --version - python 3.7 as a virtual environment
  • pip version: pip --version pip - pip 22.0.4
  • google-auth-oauthlib version: pip show google-auth-oauthlib - shows 1.0.0 ; but the code in this repo also doesn't parse the Google Cloud credentials.json afaik.

Steps to reproduce

  1. Download the credentials.json from the Cloud Console (API) under a desktop app (since running python on shell)
  2. Run code that uses it - specifically uses https://google-auth-oauthlib.readthedocs.io/en/latest/_modules/google_auth_oauthlib/flow.html#InstalledAppFlow.
  3. Keep failing on authorizing to generate token.json.
  4. Realize that the library parses 'installed' and 'web', but the credentials.json contains none of those keys.
  5. Note this is a sudden thing; it was working fine the last time I had to refresh, about a week back.

Code example

flow = InstalledAppFlow.from_client_secrets_file(
                'credentials.json', SCOPES)
creds = flow.run_console() # I just want the URL to authorize myself

Stack trace

PyEnv/lib/python3.7/site-packages/google_auth_oauthlib/flow.py", line 159, in from_client_config                                                          
raise ValueError("Client secrets must be for a web or installed app.")
ValueError: Client secrets must be for a web or installed app. 

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

The oauth JSON config for desktop is correct when I download it. Can you clarify exactly what credentials you are downloading in step 1? Maybe you can share the schema so I can identify what kind of credential they are?

Thanks for your reply! Here's the schema of the credentials.json file at the moment I had this issue:
{"WCc":{"client_id":"value","project_id":"value","Anc":"value","hVc":"value","znc":"value","s2a":"value","oNc":["value"]}}.

Those look like obfuscated keys. I'm going to try with what happens if I re-download credentails.json now, but wanted to reply with the requested info.

Edit, I just tried today, and things look back to normal! Must have been a strange day on the console that one day I tried it. I hadn't touched this codebase since I ran into the issue above, but a re-attempt today results in the schema of:

"{"installed":{"client_id":"value","project_id":"value","auth_uri":"value","token_uri":"value","auth_provider_x509_cert_url":"value","client_secret":"value","redirect_uris":["value"]}}"

so whatever happened appears to have fixed itself on the console, meaning nothing needs to change on this lib side. Looks to be an issue with the Google Cloud platform at the time that they since solved. Thanks!

Thanks for following up! I'm happy to hear that this issue was resolved.