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

Port changes everytime gspread.oauth is run #1164

Open
caynebrister1 opened this issue Jan 30, 2023 · 3 comments
Open

Port changes everytime gspread.oauth is run #1164

caynebrister1 opened this issue Jan 30, 2023 · 3 comments

Comments

@caynebrister1
Copy link

Bug:
Everytime gspread.oauth is used it uses a different port for the redirect URI which means I cant set a redirect URI for my OAuth client ID in the API dashboard. Because of the fact that I cant set a URI that will repeat the next time I run my code I constantly get the following message:
image

Steps to reproduce the behavior:

  1. Downlaod JSON for your OAuth Client ID
  2. Name the downloaded file as 'oauth_creds.json'
  3. Move the JSON gile into the 'auth' folder of your project
  4. Run the following code
import gspread

gc = gspread.oauth(
    credentials_filename='auth/oauth_creds.json'
)

The expected behavior is for a static redirect URI to be produced, that way it can be defined properly in the web console. Otherwise a URI with a different port each time can't be defined in the web console for the google API.

Environment info:

  • OS Linux Mint
  • Python 3.10.6
  • gspread 5.7.2
@lavigne958 lavigne958 added Need investigation This issue needs to be tested or investigated Bug labels Jan 31, 2023
@caynebrister1
Copy link
Author

I believe the solution may be to use 'local_server_flow', but I don't understand what value to pass to the 'client_config' parameter.

@lavigne958
Copy link
Collaborator

Hi thank you for raising this issue.

I understand your point about the port being used locally where your code run. We can look for a way to solve this.

I am confused about your second comment:

I believe the solution may be to use 'local_server_flow'

What flow do you use ? the default one ? because if you use the default flow it's already the local_server_flow which uses some port to listen locally and to me is where your issue is located. If you use the console_flow then it won't work it has been deprecated.

@lavigne958 lavigne958 added Improvement and removed Bug Need investigation This issue needs to be tested or investigated labels Feb 2, 2023
@GmGniap
Copy link

GmGniap commented May 12, 2023

This error is also happening to me. Any solution for this one?

If I updated that dynamically changing port number in Google Cloud > Redirect URI , error changed to "localhost refused to connect". I think this new error happened because of my machine permission for port , correct? How should I solve that kind of permission error? When I tried to search on internet , some suggested to setup flask server with this port on my own. Do I need to setup like this just to use gspread?

OS: macOS

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants