我最近尝试将 laravel socialite 与 laravel 5.5 集成,但出现错误:
GuzzleHttp \ Exception \ ClientException (400) Client error:
GET https://graph.facebook.com/v2.10/me? access_token=$my_token&appsecret_proof=my_proofsecret
resulted in a400 Bad Request
response: {"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 block 注释掉,它似乎工作正常,无法找出问题所在。
最佳答案
在从图形 API 获取它时,我实际上并没有为我的应用程序选择 access_token。我选择了默认的图形 API token 。 Facebook 实际上允许您生成特定于您的应用程序的访问 token ,因此您必须专门选择它。这是它的屏幕截图。
关于facebook-graph-api - Laravel 5.5 社交名媛不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46545662/