question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for Google Oauth2 post G+

See original GitHub issue

Below is an attempt to update providers/oauth2.py so that it will work with Google login after the shutdown of G+. It works currently with the email and profile scopes.

I’m not sure if it will continue to work post G+ shutdown. 🤞

-    user_info_url = 'https://www.googleapis.com/plus/v1/people/me'
+    user_info_url = 'https://www.googleapis.com/oauth2/v1/userinfo'

     @staticmethod
     def _x_user_parser(user, data):
-        emails = data.get('emails', [])
-        if emails:
-            user.email = emails[0].get('value')
-            for email in emails:
-                if email.get('type') == 'account':
-                    user.email = email.get('value')
-                    break
-
-        user.id = data.get('sub') or data.get('id')
-        user.name = data.get('displayName')
-        user.first_name = data.get('name',{}).get('givenName')
-        user.last_name = data.get('name',{}).get('familyName')
-        user.locale = data.get('language')
-        user.link = data.get('url')
-        user.picture = data.get('image',{}).get('url')
+        user.id = data.get('id')
+        user.email = data.get('email')
+        user.name = data.get('name')
+        user.first_name = data.get('given_name')
+        user.last_name = data.get('family_name')
+        user.locale = data.get('locale')
+        user.picture = data.get('picture')
         try:
             user.birth_date = datetime.datetime.strptime(data.get('birthdate'), "%Y-%m-%d")
-        except:
+        except Exception:
             user.birth_date = data.get('birthdate')
         return user

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

0reactions
ericofcommented, Nov 28, 2019

With the new release, this is solved. Closing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using OAuth 2.0 to Access Google APIs | Authorization
Google supports common OAuth 2.0 scenarios such as those for web server, client-side ... After the user approves access, the response from the...
Read more >
Setting up OAuth 2.0 - Google Cloud Platform Console Help
Go to the Google API Console OAuth consent screen page. Add required information like a product name and support email address. Click Add...
Read more >
How to Use Google OAuth 2 With a Service Account - Soliant
Learn how to leverage Google OAuth 2 with a service account for your business application from experienced developers at Soliant Consulting.
Read more >
Get OAuth 2.0 tokens | Apigee X - Google Cloud
Google Cloud. Overview ... -X POST 'https://apitest.acme.com/oauth/token' \ -d ... For detailed information on scope, see Working with OAuth2 scopes.
Read more >
Calling Google APIs via the "HTTP > Make a OAuth 2.0 ...
G Suite Reseller API · Google Sites · Google Apps Script · Gmail API; and many others. from Integromat: Open the Google Cloud...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found