Skip to content

Commit

Permalink
Fixed issues around doing the OAUTH dance for LinkedIn
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhailklassen committed Feb 26, 2019
1 parent 9557b1a commit b84b848
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions notebooks/_Appendix B - OAuth Primer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
"import os\n",
"from threading import Timer\n",
"from flask import Flask, request\n",
"from linkedin import linkedin\n",
"from linkedin import linkedin # pip install python3-linkedin\n",
"from IPython.display import display\n",
"from IPython.display import Javascript as JS\n",
"\n",
Expand All @@ -302,13 +302,19 @@
"CONSUMER_SECRET = ''\n",
"\n",
"# This value is where LinkedIn will redirect. We'll configure an embedded\n",
"# web server to be serving requests here\n",
"\n",
"RETURN_URL = 'http://localhost:5000/oauth_helper'\n",
"# web server to be serving requests here. Make sure to add this to your\n",
"# app settings\n",
"REDIRECT_URL = 'http://localhost:5000/oauth_helper'\n",
"\n",
"# A temporary file to store a code from the web server\n",
"OAUTH_FILE = 'resources/ch04-linkedin/linkedin.authorization_code'\n",
"\n",
"# These should match those in your app settings\n",
"permissions = {'BASIC_PROFILE': 'r_basicprofile',\n",
" 'EMAIL_ADDRESS': 'r_emailaddress',\n",
" 'SHARE': 'w_share',\n",
" 'COMPANY_ADMIN': 'rw_company_admin'}\n",
"\n",
"# Configure an emedded web server that accepts one request, stores a file\n",
"# that will need to be accessed outside of the request context, and \n",
"# immediately shuts itself down\n",
Expand All @@ -328,8 +334,8 @@
"# Send an OAuth request to LinkedIn, handle the redirect, and display the access\n",
"# token that's included in the redirect for the user to copy and paste\n",
"\n",
"auth = linkedin.LinkedInAuthentication(CONSUMER_KEY, CONSUMER_SECRET, RETURN_URL, \n",
" linkedin.PERMISSIONS.enums.values())\n",
"auth = linkedin.LinkedInAuthentication(CONSUMER_KEY, CONSUMER_SECRET, REDIRECT_URL, \n",
" permissions.values())\n",
"\n",
"# Display popup after a brief delay to ensure that the web server is running and \n",
"# can handle the redirect back from LinkedIn\n",
Expand Down Expand Up @@ -357,6 +363,13 @@
"app = linkedin.LinkedInApplication(auth)\n",
"print(app.get_profile())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit b84b848

Please sign in to comment.