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

Oauth2 SSO Broken after changes in build 2.155.0 #2534

Closed
0x78f1935 opened this issue Dec 13, 2024 · 1 comment
Closed

Oauth2 SSO Broken after changes in build 2.155.0 #2534

0x78f1935 opened this issue Dec 13, 2024 · 1 comment
Assignees

Comments

@0x78f1935
Copy link

0x78f1935 commented Dec 13, 2024

Version 2.154.0 seems also to be affected.

My SSO always worked. But since the release of 2.155.0 suddenly my SSO stopped working and keeps throwing a 523 status code with the error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Environment details

  • OS type and version: Win11 x64
  • Python version: Python 3.13.0
  • pip version: pip 24.3.1
  • google-api-python-client version: Version: 2.155.0
  • Cable Internet (1gbs down/120mb up)

Steps to reproduce

  1. ? Make sure to obtain an access token after login in on the SSO page from google
  2. ? Build your credentials
from google.oauth2.credentials import Credentials

# serializer contains the access_token and scope obtained after succesful google login
credentials = Credentials(token=serializer.data['access_token'], scopes=serializer.data['scope'])
  1. ? Apply credentials to service
from googleapiclient.discovery import build

# create the service we want to utilize
user_info_service = build(serviceName='oauth2', version='v2', credentials=credentials)
  1. ? Make a request to obtain user info which the user gave consent for
# Try to obtain the user info which the user gave consent for
user_info = user_info_service.userinfo().get().execute()

Full Example:

from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build

# serializer contains the access_token and scope obtained after succesful google login
credentials = Credentials(token=serializer.data['access_token'], scopes=serializer.data['scope'])
# create the service we want to utilize
user_info_service = build(serviceName='oauth2', version='v2', credentials=credentials)
# Try to obtain the user info which the user gave consent for
user_info = user_info_service.userinfo().get().execute()

The last step (4.) throws the error.

Workaround

I do have a workaround,

from google.oauth2.credentials import Credentials

credentials = Credentials(token=serializer.data['access_token'], scopes=serializer.data['scope'])

response = requests.get(
    "https://www.googleapis.com/oauth2/v2/userinfo",
    headers={"Authorization": f"Bearer {credentials.token}"}
)
user_info = response.json()

Edit: I do have to add that my workaround request takes a very long time to complete.

@0x78f1935
Copy link
Author

I am going to close this issue, due lack of response. Perhaps google server just had hickups

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

No branches or pull requests

2 participants