我的代码在本地工作正常,但在Heroku上显示错误。
例外:" GuzzleHttp \ Exception \ ClientException" 客户端错误:
POST https://github.com/login/oauth/access_token
导致404 Not Found
问题在于行$accessToken = $driver->getAccessTokenResponse($request->code);
因此它必须获取访问令牌然后为用户交换令牌,但由于某种原因显示错误。一切都在当地很好用,这只是在制作中。
public function redirectToProvider($service, Request $request)
{
$driver = Socialite::driver($service);
$accessToken = $driver->getAccessTokenResponse($request->code);
$data = $driver->getUserByToken($accessToken['access_token']);
$user = (new User())->exists($data['email']);
//
$token = JWTAuth::fromUser($user);
return response()->json([
'access_token' => $token,
'user' => [
'data' => $user,
'token' => $token
]], 200);
}
有没有人有想法?谢谢!