Social Login

Log in with your social media accounts!

Back to Social Login Support

kdoon80
kdoon80

complaining about this:

return [
        'token' => $access_token['access_token'],
        'email' => $data['email'],
    ];

Is anyone else having problem?

I changed it to:

if ($data) {
        $data = $data->getAttributes();
}
return [
        'token' =>  json_decode($access_token, true)['access_token'],
        'email' => $data['payload']['email'] ,
    ];

Now it works. Wondering why I had to do this, if the original works for other people.

Flynsarmy
Flynsarmy

Not sure what's going on here. When I do a dd($access_token) I get an array, not a string as you seem to be getting.

Just to confirm - you're on the latest version of my plugin and the code above what you pasted looks like the following, correct?

    if ( $client->isAccessTokenExpired() )
    {
        $decoded_token = json_decode($client->getAccessToken());
        $refresh_token = $decoded_token->refresh_token;
        $client->refreshToken($refresh_token);
    }

    $data = $client->verifyIdToken();

    Session::forget('access_token');

    $access_token = $client->getAccessToken();

    return [
        'token' => $access_token['access_token'],
        'email' => $data['email'],
    ];

1-2 of 2