LinkedIn user's profile picture URL returns 403 - Forbidden or Access Denied, received over LinkedIn's OAuth 2.0 Developer API

Viewed 1088

I'm currently making a LinkedIn app using the LinkedIn OAuth 2.0 Developer API with permissions r_liteprofile & r_emailaddress (Products added to my app include Share on LinkedIn & Sign In with LinkedIn).

Recently the profile images retrieved with this GET API (as per LinkedIn's own Developer documentation):

https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,localizedFirstName,localizedLastName,profilePicture(displayImage~:playableStreams))

Have started to return either 403 - Forbidden.

Full error message:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>403 - Forbidden</title>
    </head>
    <body>
        <h1>403 - Forbidden</h1>
    </body>
</html>

OR

The error Access Denied e.g.

Access Denied
You don't have permission to access "http://media-exp1.licdn.com/dms/image/C4E03AQHE3A16fLv1kQ/profile-displayphoto-shrink_800_800/0?" on this server.
Reference #18.2e5c7a5c.1589838983.25cfca02

E.g. https://media-exp1.licdn.com/dms/image/C4E03AQHE3A16fLv1kQ/profile-displayphoto-shrink_800_800/0?e=1586995200&v=beta&t=zVNycwFPGiCoLZBJBkJoN6d_n7EAVVne-nK-r75RzMo

This URL gives me Access Denied when not using a VPN, and 403 - Forbidden when using a VPN.

This tells me my IP address is being logged and some security mechanism kicking in if I access the URL directly a few times.

However about two months ago, I could directly link to this profile image URL from my app and it would load just fine.

If LinkedIn has made some changes and I can no longer link to the profile image URL - how else can I access the user's profile image?

Any help you can provide would be much appreciated!

1 Answers

Check the identifierExpiresInSeconds of your identifier. You can see the field in the docs: https://docs.microsoft.com/en-us/linkedin/shared/references/v2/profile/profile-picture#profile-api-sample-response

I created a Linkedin app to test this, and it works just fine for me. I can access the profile picture from different IPs, too. The response I am getting has an identifierExpiresInSeconds of 1596067200, which is in exactly two months from the time of request.

That matches with your description of the issue - it worked fine two months ago. Now your identifier seems to have expired. You will need to perform another API call to get a valid picture identifier.

Related