1

Trying to get Get Google OAuth credentials, as mentioned in this sample:

google-oauthlib-tool --client-secrets c:\temp\client_secret_NNNN.json \ --credentials c:\temp\credentials.json \ --scope https://www.googleapis.com/auth/assistant-sdk-prototype \ --save 

But calling this command there is no credentials.json file created. Any suggestions?

client_secret_NNNN.json:

{ "installed": { "client_id": "NNNN.apps.googleusercontent.com", "project_id": "personal-stuff-54a54", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://accounts.google.com/o/oauth2/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "redirect_uris": [ "urn:ietf:wg:oauth:2.0:oob", "http://localhost" ] } } 

Log:

Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=633452378895-dg56psuf7er87nh1ehmoluekkkv0qj0j.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fassistant-sdk-prototype&state=6vqzd8wqETrkbsAwSVbvlrFKcJ4Vs8&access_type=offline Traceback (most recent call last): File "c:\users\konopko\appdata\local\programs\python\python36-32\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\users\konopko\appdata\local\programs\python\python36-32\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\konopko\AppData\Local\Programs\Python\Python36-32\Scripts\google-oauthlib-tool.exe\__main__.py", line 9, in <module> File "c:\users\konopko\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 722, in __call__ return self.main(*args, **kwargs) File "c:\users\konopko\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 697, in main rv = self.invoke(ctx) File "c:\users\konopko\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "c:\users\konopko\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 535, in invoke return callback(*args, **kwargs) File "c:\users\konopko\appdata\local\programs\python\python36-32\lib\site-packages\google_auth_oauthlib\tool\__main__.py", line 104, in main creds = flow.run_local_server() File "c:\users\konopko\appdata\local\programs\python\python36-32\lib\site-packages\google_auth_oauthlib\flow.py", line 420, in run_local_server self.fetch_token(authorization_response=authorization_response) File "c:\users\konopko\appdata\local\programs\python\python36-32\lib\site-packages\google_auth_oauthlib\flow.py", line 239, in fetch_token kwargs.setdefault('client_secret', self.client_config['client_secret']) KeyError: 'client_secret' 
2
  • Do you mean that it is not generated at all, or not generated in your app project directory? Your command directs it to c:\temp, not to your app bundle.CommentedMay 24, 2018 at 19:06
  • @JereKäpyaho I expecting file going to be created in c:\temp but there is nothingCommentedMay 24, 2018 at 19:08

1 Answer 1

6

Your client_secret_NNNN.json should have a key client_secret, which is missing in your example. Go to https://console.developers.google.com/apis/credentials. You see a list of your OAuth2 client IDs. On the very right side of each client ID, there is a pen icon. Click it. On the page which now opens, you will see Client ID, Client secret, and Creation date. The Client secret should go into client_secret. The page also offers a download of the client secrets file, which then looks like this:

{ "installed": { "client_id": "your-client-id.apps.googleusercontent.com", "project_id": "your-project-id", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://accounts.google.com/o/oauth2/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_secret": "your-very-secret-token-here", "redirect_uris": [ "urn:ietf:wg:oauth:2.0:oob", "http://localhost" ] } } 
4
  • Can't find Client secret field in page you mentioned, can see only Client ID ans Creation date. Donwloaded file not contains Client secret too.CommentedMay 25, 2018 at 9:46
  • Got Client secret in web ID, then download json. But trying to get credentials I've got redirect_uri_mismatch error. Request details: response_type=code client_id=NNNN.apps.googleusercontent.com redirect_uri=http://localhost:8080/ scope=https://www.googleapis.com/auth/assistant-sdk-prototype state=dgEOR2ppQuoe8Qo6Z2UW3njf6K1j0S access_type=offline. Google says: The redirect URI in the request, localhost:8080, does not match the ones authorized for the OAuth client.CommentedMay 25, 2018 at 11:08
  • This is strange. Could you tell more what is happening on your computer? I would expect the browser to be opened. Is there an error there (such es HTTP 40x or 500)?
    – Adrian W
    CommentedMay 25, 2018 at 15:04
  • I've just created new OAuth 2 key with type Other and this works great for now! Thanks AdrianCommentedMay 25, 2018 at 15:13

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.