Skip to content

Commit bafff0b

Browse files
committed
removed outdated linkedin compliance fixes
1 parent 29ba9af commit bafff0b

File tree

5 files changed

+15
-69
lines changed

5 files changed

+15
-69
lines changed

HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ UNRELEASED
55
++++++++++
66

77
- Add initial support for OAuth Mutual TLS (draft-ietf-oauth-mtls)
8+
- Removed outdated LinkedIn Compliance Fixes
89

910
v1.3.0 (6 November 2019)
1011
++++++++++++++++++++++++

docs/examples/linkedin.rst

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,31 @@ command line interactive example below.
1313
>>> client_id = '<the id you get from linkedin>'
1414
>>> client_secret = '<the secret you get from linkedin>'
1515
16+
>>> # LinkedIn OAuth2 requests require scope and redirect_url parameters.
17+
>>> # Ensure these values match the auth values in your LinkedIn App
18+
>>> # (see auth tab on LinkedIn Developer page)
19+
>>> scope = ['r_liteprofile']
20+
>>> redirect_url = 'http://127.0.0.1'
21+
1622
>>> # OAuth endpoints given in the LinkedIn API documentation
17-
>>> authorization_base_url = 'https://www.linkedin.com/uas/oauth2/authorization'
18-
>>> token_url = 'https://www.linkedin.com/uas/oauth2/accessToken'
23+
>>> authorization_base_url = 'https://www.linkedin.com/oauth/v2/authorization'
24+
>>> token_url = 'https://www.linkedin.com/oauth/v2/accessToken'
1925
2026
>>> from requests_oauthlib import OAuth2Session
21-
>>> from requests_oauthlib.compliance_fixes import linkedin_compliance_fix
2227
2328
>>> linkedin = OAuth2Session(client_id, redirect_uri='http://127.0.0.1')
24-
>>> linkedin = linkedin_compliance_fix(linkedin)
2529
2630
>>> # Redirect user to LinkedIn for authorization
2731
>>> authorization_url, state = linkedin.authorization_url(authorization_base_url)
28-
>>> print 'Please go here and authorize,', authorization_url
32+
>>> print("Please go here and authorize, {}").format(authorization_url))
2933
3034
>>> # Get the authorization verifier code from the callback url
31-
>>> redirect_response = raw_input('Paste the full redirect URL here:')
35+
>>> redirect_response = input('Paste the full redirect URL here:')
3236
3337
>>> # Fetch the access token
34-
>>> linkedin.fetch_token(token_url, client_secret=client_secret,
35-
... authorization_response=redirect_response)
38+
>>> linkedin.fetch_token(token_url,client_secret=client_secret,
39+
... include_client_id=True,authorization_response=redirect_response)
3640
3741
>>> # Fetch a protected resource, i.e. user profile
38-
>>> r = linkedin.get('https://api.linkedin.com/v1/people/~')
39-
>>> print r.content
42+
>>> r = linkedin.get('https://api.linkedin.com/v2/me')
43+
>>> print(r.content)

requests_oauthlib/compliance_fixes/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from .facebook import facebook_compliance_fix
44
from .fitbit import fitbit_compliance_fix
5-
from .linkedin import linkedin_compliance_fix
65
from .slack import slack_compliance_fix
76
from .instagram import instagram_compliance_fix
87
from .mailchimp import mailchimp_compliance_fix

requests_oauthlib/compliance_fixes/linkedin.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/test_compliance_fixes.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -99,43 +99,6 @@ def test_refresh_token(self):
9999
self.assertEqual(token["refresh_token"], "refresh")
100100

101101

102-
class LinkedInComplianceFixTest(TestCase):
103-
def setUp(self):
104-
mocker = requests_mock.Mocker()
105-
mocker.post(
106-
"https://www.linkedin.com/uas/oauth2/accessToken",
107-
json={"access_token": "linkedin"},
108-
)
109-
mocker.post(
110-
"https://api.linkedin.com/v1/people/~/shares",
111-
status_code=201,
112-
json={
113-
"updateKey": "UPDATE-3346389-595113200",
114-
"updateUrl": "https://www.linkedin.com/updates?discuss=abc&scope=xyz",
115-
},
116-
)
117-
mocker.start()
118-
self.addCleanup(mocker.stop)
119-
120-
linkedin = OAuth2Session("someclientid", redirect_uri="https://i.b")
121-
self.session = linkedin_compliance_fix(linkedin)
122-
123-
def test_fetch_access_token(self):
124-
token = self.session.fetch_token(
125-
"https://www.linkedin.com/uas/oauth2/accessToken",
126-
client_secret="someclientsecret",
127-
authorization_response="https://i.b/?code=hello",
128-
)
129-
self.assertEqual(token, {"access_token": "linkedin", "token_type": "Bearer"})
130-
131-
def test_protected_request(self):
132-
self.session.token = {"access_token": "dummy-access-token"}
133-
response = self.session.post("https://api.linkedin.com/v1/people/~/shares")
134-
url = response.request.url
135-
query = parse_qs(urlparse(url).query)
136-
self.assertEqual(query["oauth2_access_token"], ["dummy-access-token"])
137-
138-
139102
class MailChimpComplianceFixTest(TestCase):
140103
def setUp(self):
141104
mocker = requests_mock.Mocker()

0 commit comments

Comments
 (0)