need a little nudge with OAuth setup

Looking for some assistance with AppServiceProvider for OAuth integration.

Here's what I'm seeing currently. My users are being stored in a database. I'm looking to use Twitter and Facebook providers for OAuth.

services.php has

'twitter' => [
        'client_id' => env('TWITTER_CLIENT_ID'),
        'client_secret' => env('TWITTER_CLIENT_SECRET'),
        'redirect' => env('APP_URL') . '/oauth/twitter/callback',
    ],

    'facebook' => [
        'client_id' => env('FACEBOOK_CLIENT_ID'),
        'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
        'redirect' => env('APP_URL') . '/oauth/facebook/callback',
    ],

oauth.php has the providers 'providers => ['twitter', 'facebook'] and configured routes. Inside AppServiceProvider boot method I have

OAuth::provider('twitter')->withUserData(function ($user) {
            ray($user);
            return [
                'name' => $user->getName(),
                'provider' => 'twitter',
                'created_at' => now()->format('Y-m-d'),
                'avatar' => $user->avatar_original,
            ];
        });

        OAuth::provider('facebook')->withUserData(function ($user) {
            ray($user);
            return [
                'name' => $user->getName(),
                'provider' => 'facebook',
                'created_at' => now()->format('Y-m-d'),
                'avatar' => $user->avatar_original,
            ];
        });

Here's the curious thing. I can register fine using one service but if I logout and try to register with the other, it doesn't work and actually logs me in with the first user . If I reset the db and use the other service first, that also works.

Both services have 2 different email addresses, so there's no conflict.

On my second registration attempt, I don't even seem to get an instance of Laravel\Socialite\Contracts\User returned (the ray call gives me nothing).

So, not sure whether it's an issue with where I have my changes to AppServiceProvider or it's a bug.

>>>>>>> Unanswered <<<<<<<
0 Replies
1 Follower