Open fgalan opened 6 years ago
Hi, no question is naive 😄 You can get `client_secret.json' file from Google Developer Console -> APIs and Services -> Crednetials. You'll need to create a new Web Application credentials, fill in the details and you'll be able to download the file.
The credentials.json
file is generated during runtime and you should not commit to your source control system.
Thank you for your help! :)
Following the link you send me, I have been able to create Web Application credentials and download a .json file which I saved as client_secret.json, with the following content:
{
"web": {
"client_id": "...",
"project_id": "...",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://www.googleapis.com/oauth2/v3/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "..."
}
}
but when I try to run the script I get this error:
C:\Python27\lib\site-packages\oauth2client\_helpers.py:255: UserWarning: Cannot access credentials.json: No such file or directory
warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
Traceback (most recent call last):
File "D:/python-workspace/sandbox/gphoto_manager.py", line 21, in <module>
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
File "C:\Python27\lib\site-packages\oauth2client\_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Python27\lib\site-packages\oauth2client\client.py", line 2135, in flow_from_clientsecrets
cache=cache)
File "C:\Python27\lib\site-packages\oauth2client\clientsecrets.py", line 165, in loadfile
return _loadfile(filename)
File "C:\Python27\lib\site-packages\oauth2client\clientsecrets.py", line 126, in _loadfile
return _validate_clientsecrets(obj)
File "C:\Python27\lib\site-packages\oauth2client\clientsecrets.py", line 101, in _validate_clientsecrets
prop_name, client_type))
oauth2client.clientsecrets.InvalidClientSecretsError: Missing property "redirect_uris" in a client type of "web".
Maybe I did something wrong to generate the credentials. I needed to fill a form named "OAuth consent screen" asking some information and not sure if I provide them all correctly... (they were asking my for homepage link and application logo... which sounds a bit weird to me as I'm not providing a full web application but I'm going to use credentials from a script)
@ido-ran what do you think? Any idea of what can be happening and the solution, please? Thanks in advance!
@ido-ran: Thank you for the example!
@fgalan just to let you know, it did work for me. I also downloaded client_id.json, but according the first line of your traceback ('Cannot access credentials.json: No such file or directory'), I modified quickstart.py in lines 14 and 17 to provide the full path pointing to credentials.json
and client_id.json
. After starting the script, the default browser opened with a page, where I needed to log in with my google account. After doing so, the program did indeed list the 10 most recent albums.
Hi!
How can I get the credentials.json and client_secret.json files that the example program needs to authenticate? I guess they should be in some part of my google account, but don't know how I get them.
Maybe the question is very naïve, but I'm new in Google API and after checking documentation it is not clear how to get them (or maybe I haven't find the right documentation to read)
Thanks!