Reputation: 694
Context:
I'm developing a "login with LinkedIn" feature on Laravel 11 using socialite. This requires 2 endpoints:
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:
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