首页 > 解决方案 > Laravel Socialite 使用 Google 登录 - userFromToken

问题描述

我正在尝试使用 google 实现 Laravel 社交登录,但我遇到了给定的错误。

message: "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"}"

这是我的 Laravel 代码。

  public function Sociallogin($provider,Request $request)
  {

      $token = $request->input('token');
      $user = Socialite::driver($provider)->userFromToken($token);

      die($user);
  }

请注意,此代码在使用 Facebook 登录时有效。请帮我。

谢谢!

标签: phplaravel

解决方案


是的,最后我找到了解决方案,发生的错误是我提供了错误的谷歌开发者帐户凭据。如果有人发生同样的错误,请验证凭据。


推荐阅读