How can i figure out "Not enough permissions to access: GET /me" error?

148 Views Asked by At

I am trying to add LinkedIn auth on my laravel app using socialite package. But I'm getting the following error:

Client error: `GET https://api.linkedin.com/v2/me?projection=%28id%2CfirstName%2ClastName%2CprofilePicture%28displayImage~%3AplayableStreams%29%2CvanityName%29` resulted in a `403 Forbidden` response: {"serviceErrorCode":100,"message":"Not enough permissions to access: GET /me","status":403}

I got the access of the Share on LinkedIn and Sign In with LinkedIn using OpenID Connect products.

I have created the access token for it.

2

There are 2 best solutions below

0
On

That error indicates that the LinkedIn API is rejecting the request because the user's access token doesn't have the required permissions to access the requested endpoint. Sometimes the user might have restricted access to their profile information. You can check the LinkedIn account settings allow third-party applications to access the required data.

You can also check that your Laravel Socialite configuration specifies the correct LinkedIn scopes during the authentication process. In your config/services.php file under the linkedin configuration make sure you have included the necessary scopes.

0
On

the error you are getting is that your app is using openid and you try to use the old way which is using GET https://api.linkedin.com/v2/me

since your application is using openid you should use

GET https://api.linkedin.com/v2/userinfo
Authorization: Bearer <access token>

the solution is that in your file services.php replace

`'linkedin' => [
    'client_id' => env('LINKEDIN_ID'),
    'client_secret' => env('LINKEDIN_SECRET'),
    'redirect' => env('LINKEDIN_URL'),
]`

with this `

'linkedin-openid' => [
        'client_id' => env('LINKEDIN_ID'),
        'client_secret' => env('LINKEDIN_SECRET'),
        'redirect' => env('LINKEDIN_URL'),
    ],

`

and Socialite::driver('linkedin-openid')...; instead of Socialite::driver('linkedin')...