我最近尝试将 Laravel Socialite 与 Laravel 5.5 集成,但是遇到了如下错误:
GuzzleHttp \ Exception \ ClientException (400) 客户端错误:
GET https://graph.facebook.com/v2.10/me?access_token=$my_token&appsecret_proof=my_proofsecret
的响应状态为400 Bad Request
:{"error":{"message":"Error validating access token: Session has expired on Tuesday, 03-Oct-17 05:00:00 PDT. The current (truncated...)}
现在我已经进行了一定的调试,基本上这个错误是由 FacebookProvider.php
中第89行代码造成的。
protected function getUserByToken($token)
{
$meUrl = $this->graphUrl.'/'.$this->version.'/me?access_token='.$token.'&fields='.implode(',', $this->fields);
if (! empty($this->clientSecret)) {
$appSecretProof = hash_hmac('sha256', $token, $this->clientSecret);
$meUrl .= '&appsecret_proof='.$appSecretProof;
}
$response = $this->getHttpClient()->get($meUrl, [
'headers' => [
'Accept' => 'application/json',
],
]);
return json_decode($response->getBody(), true);
}
这是一行:
$appSecretProof = hash_hmac('sha256', $token, $this->clientSecret);
如果我将整个if else代码块注释掉,似乎程序可以正常运行,但我无法找出问题所在。