Skip to content

Commit

Permalink
[frontend/auth] remove legacy LinkedIn compliance fix (#819)
Browse files Browse the repository at this point in the history
* remove linkedin compliance

* update authorization base & token urls
  • Loading branch information
Drumor committed May 30, 2022
1 parent 66ad30f commit 035583b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions inginious/frontend/plugins/auth/linkedin_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
import flask

from requests_oauthlib import OAuth2Session
from requests_oauthlib.compliance_fixes import linkedin_compliance_fix

from inginious.frontend.user_manager import AuthMethod

authorization_base_url = 'https://www.linkedin.com/uas/oauth2/authorization'
token_url = 'https://www.linkedin.com/uas/oauth2/accessToken'
authorization_base_url = 'https://www.linkedin.com/oauth/v2/authorization'
token_url = 'https://www.linkedin.com/oauth/v2/accessToken'
scope = ["r_liteprofile", "r_emailaddress"]


Expand All @@ -25,7 +24,6 @@ class LinkedInAuthMethod(AuthMethod):
"""
def get_auth_link(self, auth_storage, share=False):
linkedin = OAuth2Session(self._client_id, scope=scope + (["w_share"] if share else []), redirect_uri=flask.request.url_root + self._callback_page)
linkedin = linkedin_compliance_fix(linkedin)
authorization_url, state = linkedin.authorization_url(authorization_base_url)
auth_storage["oauth_state"] = state
return authorization_url
Expand All @@ -38,7 +36,7 @@ def callback(self, auth_storage):
r = linkedin.get('https://api.linkedin.com/v2/me?projection=(id,localizedFirstName,localizedLastName)')
profile = json.loads(r.content.decode('utf-8'))
r = linkedin.get('https://api.linkedin.com/v2/clientAwareMemberHandles?q=members&projection=(elements*(primary,type,handle~))')
result = json.loads(r.content.decode('utf-8'))
result = json.loads(r.content.decode('utf-8'))
for contact in result["elements"]:
if contact["type"] == "EMAIL":
profile["emailAddress"] = contact["handle~"]["emailAddress"]
Expand Down

0 comments on commit 035583b

Please sign in to comment.