[EDIT] Just to prevent you from reading this: I already found the answer myself and also posted the anser here below.. :)
I'm building a website using the (excellent) Python Flask framework, and I'm now building integration with LinkedIn. For this I used the example I found here which works by returning the r_basicprofile data.
I now want to return more information from linkedin, so I changed the scope
from 'r_basicprofile'
to 'r_emailaddress'
. It correctly goes to LinkedIn and (in addition to the basicprofile info) it also asks correctly for access to the email address. After entering my username and password, I only get the basicprofile back in a json though. The only part which I don't understand from the example code is line 54, which gets the actual information from LinkedIn. The function is as follows:
@app.route('/login/authorized')
def authorized():
resp = linkedin.authorized_response()
if resp is None:
return 'Access denied: reason=%s error=%s' % (
request.args['error_reason'],
request.args['error_description']
)
session['linkedin_token'] = (resp['access_token'], '')
me = linkedin.get('people/~') # <== HOW can I get this line to return the email address?
return jsonify(me.data)
The json which currently gets returned is as follows:
{
"firstName": "MyFirstName",
"headline": "Developer",
"lastName": "MyLastName",
"siteStandardProfileRequest": {
"url": "https://www.linkedin.com/profile/view?id=12345678&authType=name&authToken=XXXXXXXXX=api*a1234567*s1234567*"
}
}
Does anybody know how I can actually get the email address after correctly authorizing my app for the email address?
All tips are welcome!
Nevermind! I already found it!
I need to use the following to get the email address:
emailAddress = linkedInApp.get('people/~/email-address')
print emailAddress.data
Next time I'll read a bit more before I post. Thanks for your attention anyway!
ps: I can only accept my own answer in 2 days. So excuse me if you came to this question because you saw no answer was accepted yet. If someone else can copy paste my answer I'll be happy to accept their answer so that this question can go down the list of forgotten questions.. :)