@@ -9,31 +9,41 @@ command line interactive example below.
99
1010.. code-block :: pycon
1111
12+ >>> # Imports
13+ >>> import os
14+ >>> from requests_oauthlib import OAuth2Session
15+
16+ >>> # Set environment variables
17+ >>> os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
18+
1219 >>> # Credentials you get from registering a new application
1320 >>> client_id = '<the id you get from linkedin>'
1421 >>> client_secret = '<the secret you get from linkedin>'
1522
16- >>> # 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+ >>> # LinkedIn OAuth2 requests require scope and redirect_url parameters.
24+ >>> # Ensure these values match the auth values in your LinkedIn App
25+ >>> # (see auth tab on LinkedIn Developer page)
26+ >>> scope = ['r_liteprofile']
27+ >>> redirect_url = 'http://127.0.0.1'
1928
20- >>> from requests_oauthlib import OAuth2Session
21- >>> from requests_oauthlib.compliance_fixes import linkedin_compliance_fix
29+ >>> # OAuth endpoints given in the LinkedIn API documentation
30+ >>> authorization_base_url = 'https://www.linkedin.com/oauth/v2/authorization'
31+ >>> token_url = 'https://www.linkedin.com/oauth/v2/accessToken'
2232
23- >>> linkedin = OAuth2Session(client_id, redirect_uri='http://127.0.0.1')
24- >>> linkedin = linkedin_compliance_fix(linkedin)
33+ >>> linkedin = OAuth2Session(client_id, redirect_uri='http://127.0.0.1', scope=scope)
2534
2635 >>> # Redirect user to LinkedIn for authorization
2736 >>> authorization_url, state = linkedin.authorization_url(authorization_base_url)
28- >>> print ' Please go here and authorize,', authorization_url
37+ >>> print(f" Please go here and authorize: { authorization_url}")
2938
3039 >>> # Get the authorization verifier code from the callback url
31- >>> redirect_response = raw_input ('Paste the full redirect URL here:')
40+ >>> redirect_response = input ('Paste the full redirect URL here:')
3241
3342 >>> # Fetch the access token
3443 >>> linkedin.fetch_token(token_url, client_secret=client_secret,
44+ ... include_client_id=True,
3545 ... authorization_response=redirect_response)
3646
3747 >>> # Fetch a protected resource, i.e. user profile
38- >>> r = linkedin.get('https://api.linkedin.com/v1/people/~ ')
39- >>> print r.content
48+ >>> r = linkedin.get('https://api.linkedin.com/v2/me ')
49+ >>> print( r.content)
0 commit comments