Socialite Auth: How do I include more than one redirect uri for each service?

Or how can i dynamically set the redirect uri? I’m constantly having to solve merge conflicts because my local and production server use different redirects. Or maybe I should add services.php to gitignore?

my service.php

'google' =>[
    'client_id'=> env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect' =>'http://localhost:3000/login/google/callback', 
],

I want to include a uri for production like

http://example.com/login/google/callback

I’ve tried using an array which didn’t work

Answer

You could set this dynamically with url(). This way it would update appropriately on any environment.

In your case it would look like this:

'google' =>[
    'client_id'=> env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect' => url('login/google/callback'), 
],

Leave a Reply

Your email address will not be published. Required fields are marked *