I am trying to get a user's email address from their Linked In.
I complete the whole OAuth 2.0 Authorization Code Flow and get an access token but when I make a GET request to the endpoint https://api.linkedin.com/v2/me?projection=(email-address)
, it returns a 403 (Forbidden) HTTP status code.
Here is what happens:
When I specify r_liteprofile r_email-address
as the permission in the scope
parameter when making a request for an authorization code, and when asking for data, as the fields
, the parameter projection=(localizedFirstName, localizedLastName, email-address)
, I get a 200 HTTP Status code but in the result JSON, I get only the localizedFirstName
and localizedLastName
values.
If I specify just the r_emailaddress
permission in the scope
parameter and projection=(email-address)
when asking for data, I receive a 403 (Forbidden) Status Code.
If I specify just r_emailaddress
in the scope
field and leave out specifying any fields, i.e. I hit the https://api.linkedin.com/v2/me
endpoint without any parameters (but the access token sent appropriately in the Authorization
header as a Bearer
scheme token), I get a 403 (Forbidden) HTTP Status Code.
My application does have permission for r_emailaddress
as that is a basic permission that is granted to all applications upon creation and does not need approval.
Am I hitting the right endpoint for getting the email address? Everything seems to be alright but I still get a 403. What's going on?
The request to retrieve the email address is:
GET https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))
You need to request the r_emailaddress scope to use this endpoint.
See https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin?context=linkedin/consumer/context for reference.