Created
March 11, 2013 21:31
-
-
Save zain/5137965 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @login_required | |
| def linked_in(request): | |
| REDIRECT_URI = 'http://127.0.0.1:8000/linkedin' | |
| if 'clear' in request.GET: | |
| del request.session['linkedin'] | |
| print "clear." | |
| elif not 'linkedin' in request.session: | |
| request.session['person'] = request.GET.get('person') | |
| request.session['linkedin'] = 'authing' | |
| params = urllib.urlencode({ | |
| 'response_type': 'code', | |
| 'client_id': 'b3o4mc5o3awp', | |
| 'scope': 'r_basicprofile r_network', | |
| 'state': 'omgmailsaiodfsocfuas8df86328fjasdfzxdfsl', | |
| 'redirect_uri': REDIRECT_URI, | |
| }).replace('r_basicprofile+r_network', 'r_basicprofile%20r_network') | |
| url = 'https://www.linkedin.com/uas/oauth2/authorization?%s' % params | |
| print "redirecting to: %s" % url | |
| return redirect(url) | |
| elif 'code' in request.GET: | |
| code = request.GET.get('code') | |
| params = { | |
| 'grant_type': 'authorization_code', | |
| 'code': code, | |
| 'redirect_uri': REDIRECT_URI, | |
| 'client_id': 'b3o4mc5o3awp', | |
| 'client_secret': 'XjGfyadGSWvj1QSD' | |
| } | |
| print params | |
| r = requests.post("https://www.linkedin.com/uas/oauth2/accessToken", data=params) | |
| print r.json | |
| person = request.GET.get('person', 'Jason Corwin') | |
| firstname, lastname = person.split() | |
| return render(request, 'mobile/linkedin2.html',{ | |
| 'person': person, | |
| 'firstname': firstname, | |
| 'lastname': lastname | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment