Skip to content

Error like "Not enough permissions to access: GET /me" #58

@rimoi

Description

@rimoi

if you're like me, you have this error: [Not enough permissions to access: me.GET.NO_VERSION

I trigger when I try to make this call:

 #[Route('/oauth/linkedin/check', name: 'connect_linkedin_check')]
 public function checkLinkedin( ClientRegistry $clientRegistry)
 {
       $client = $clientRegistry->getClient('linkedin');

        $user = $client->fetchUser(); //  <--- it comes exactly from this call, as it uses LinkedIn's proprietary API https://api.linkedin.com/v2/me

        dd($user);

        return $this->redirectToRoute('accueil');
 }

I replaced it with this and now I have no more errors and I can retrieve data from the client :

#[Route('/oauth/linkedin/check', name: 'connect_linkedin_check')]
 public function checkLinkedin( ClientRegistry $clientRegistry)
 {
       
        $client = $clientRegistry->getClient('linkedin');
        $accessToken = $client->getAccessToken();

        $response = $client->getOAuth2Provider()->getAuthenticatedRequest( 'GET',
             'https://api.linkedin.com/v2/userinfo',
             $accessToken
         );   // <--- endpoint standard OpenID Connect.

        $userinfo = $client->getOAuth2Provider()->getParsedResponse($response);

        dd($userinfo);

        return $this->redirectToRoute('accueil');
 }

```


Hopefully this will help some of you and save you a day of dealing with this problem.


NB : I won't put it here, but make sure you've set up the ‘knpu_oauth2_client.yaml’ file properly 😉 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions