davidvnog
davidvnog

Reputation: 694

Login with Linkedin - not redirecting back to my app

Context:

I'm developing a "login with LinkedIn" feature on Laravel 11 using socialite. This requires 2 endpoints:

  1. One that redirects the user to a LinkedIn login page
  2. One that LinkedIn redirects to if login was successful

Expected vs. Actual Behavior:

I have checked that my application is configured with the correct redirect url. See my services.php below:

    'linkedin-openid' => [
        'client_id' => env('LINKEDIN_CLIENT_ID'),
        'client_secret' => env('LINKEDIN_CLIENT_SECRET'),
        'redirect' => 'http://localhost:5173/linkedin/callback',
    ]

I have also double checked if this same url is configured in my app in my developer account: LinkedIn developer account redirect url settings

And finally, this is my service that creates the url that takes the user to the LinkedIn login page:

class LinkedInAuthLinkService
{
    public function execute(): string
    {
        $state = Str::random(40);
        Cache::put("linkedin_state_{$state}", auth()->id(), now()->addMinutes(60));

        return Socialite::driver(SocialProviders::LINKEDIN)
            ->stateless()
            ->with(['state' => $state])
            ->redirect()
            ->getTargetUrl();
    }
}

I tried to reach out to LinkedIn support but they said I should post this on Stack Overflow.

Upvotes: 4

Views: 351

Answers (1)

Uday Kumar
Uday Kumar

Reputation: 1

Looks like LinkedIn has finally fixed the issue.

Upvotes: -1

Related Questions