I have a Vue application which login user with Google JS SDK. Javascript get access_token and send this token to Laravel. What I expect is the Socialite should be able to login to Google API with this token and get user data and login user. I tried this
// $token is that one which Javascript send to Laravel
$user_google_data = Socialite::driver('google')->userFromToken($token);
But this throws me an error:
Copy
resulted in a `401 Unauthorized` response:
{
"error": "invalid_request",
"error_description": "Invalid Credentials"
}
{"exception":"[object] (GuzzleHttp\\Exception\\ClientException(code: 401): Client error: `GET https://www.googleapis.com/oauth2/v3/userinfo?prettyPrint=false` resulted in a `401 Unauthorized` response:
{
\"error\": \"invalid_request\",
\"error_description\": \"Invalid Credentials\"
}
The credentials should be valid because if I change the credentials I get another error invalid client. I am not sure if the js token is valid too or how to use it properly. The problem could be if the token would be one time token cause I get this token from online application which send this token to Google API. But I dont know. Does somebod know what is wrong with this flow? Thnaks.