Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding an example of getting things with the tokens in the db

  • Loading branch information...
commit a85036412b80907d0e226c6e98e1fac2bbbaafb2 1 parent ea8d26a
@synedra synedra authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 hellodjango/linkedin/views.py
View
12 hellodjango/linkedin/views.py
@@ -49,10 +49,16 @@ def oauth_login(request):
@login_required
def home(request):
now = datetime.datetime.now()
- html = "<html><body>It is now %s.</body></html>" % now
- html += request.user.get_profile().oauth_token
+ html = "<html><body>"
+ token = oauth.Token(request.user.get_profile().oauth_token,request.user.get_profile().oauth_secret)
+ client = oauth.Client(consumer,token)
+ headers = {'x-li-format':'json'}
+ url = "http://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline)"
+ resp, content = client.request(url, "GET", headers=headers)
+ profile = json.loads(content)
+ html += profile['firstName'] + " " + profile['lastName'] + "<br/>" + profile['headline']
return HttpResponse(html)
-
+
@login_required
def oauth_logout(request):
# Log a user out using Django's logout function and redirect them
Please sign in to comment.
Something went wrong with that request. Please try again.