0

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.