I need to use the ezsheets module which requires the use of both Google Drive and Google Spreadsheets APIs. I enabled them and have managed to gain the required credentials, which I passed in the python project folder.
According to Google Spreadsheets documentation, the next step should be gaining the two required token files ( one for each API ) in the same directory where the credentials is placed. Allegedly, you’re supposed to do this by simply typing
import spreadsheets
However, when I do this, the thing that pops up instead of an authentication window, is an error message
In Pycharm console, the message that pops up is as follows :
Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=934755340326-1qlpikthrsdblrrnodqea6k4kjtiugfb.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fspreadsheets&state=yxr0mqsA7K0qxoJ2gaCtVrJyA8Cf87&access_type=offline
So I tried changing the OAuth 2.0. client authorized redirect URI to the link python gave out in the aforementioned message. However, nothing changed. Then I changed it to the http://localhost:8080 ( since the error message gave this one out ), but the problem persists.
Is there any way I can solve this problem, or acquire the token files in literally any other way ? I would be immensely thankful if anyone could help me out with this, as it prevents me to progress any further, which is detrimental for a beginner such as myself.
EDIT: I also added the JSON credentials file to system variables. It didn’t change the result of the import ezsheets command.
Advertisement
Answer
You have run your code with a redirect uri of http://localhost:8080/
but you have not added http://localhost:8080/
as a valid redirect URI in Google Developer console.
You need to go to Google Developer console for your Web credentials and edit that and set the redirect uri properly
Here is an example of how to add the redirect uri How to add redirect URI. Remember it must match exactly, that means the / at the end is important.