无法生成Google OAuth 2令牌

时间:2019-01-22 13:08:58

标签: laravel-5 google-oauth2 guzzlehttp

我正在尝试在laravel应用程序上使用GuzzleHttp生成Google OAuth 2令牌,但出现此错误消息-

Client error: `POST https://accounts.google.com/o/oauth2/token` resulted in a `400 Bad Request` response: { "error": "invalid_grant", "error_description": "Bad Request" }

这是我的代码

 $client = new Client();
        $call = $client->post(env('AUTH_URL'), [
            'form_params' => [
                'client_id' => env('CLIENT_ID'),
                'client_secret' => env('CLIENT_SECRET'),
                'redirect_uri' => env('CALLBACK_URL'),
                'grant_type' => 'authorization_code',
                'scope' => env('SCOPE'),
                'code' => env('AUTH_CODE')
            ]
        ]);
        $response = json_decode($call->getBody()->getContents(), true);
        dd($response);

请问这里可能是什么问题?

0 个答案:

没有答案