laravel - 在 laravel-passport-social-grant 包上获取 inv

使用的包是:https://github.com/coderello/laravel-passport-social-grant

我已经按照以下位置提供的教程进行了所有预期更改: https://medium.com/@hivokas/api-authentication-via-social-networks-for-your-laravel-application-d81cfc185e60

网址:

http://myurl.com/oauth/token

输出:

{
    "error": "invalid_credentials",
    "error_description": "The user credentials were incorrect.",
    "message": "The user credentials were incorrect."
}

postman使用的参数如下:

    grant_type' => 'social', // static 'social' value
        'client_id' => $clientId, // client id
        'client_secret' => $clientSecret, // client secret
        'provider' => $providerName, // name of provider (e.g., 'facebook', 'google' etc.)
        'access_token' => $providerAccessToken, // access token issued by specified provider
    ],

这可能是什么问题?

最佳答案

对于 Facebook,您需要在 services.php 中包含 client_id 和 secret Socialite的FacebookProvider里面的代码

protected function getUserByToken($token)
{
    $this->lastToken = $token;

    $params = [
        'access_token' => $token,
        'fields' => implode(',', $this->fields),
    ];

    if (! empty($this->clientSecret)) {
        $params['appsecret_proof'] = hash_hmac('sha256', $token, $this->clientSecret);
    }

    $response = $this->getHttpClient()->get($this->graphUrl.'/'.$this->version.'/me', [
        'headers' => [
            'Accept' => 'application/json',
        ],
        'query' => $params,
    ]);

    return json_decode($response->getBody(), true);
}

所以,谷歌有点像没有 secret 的工作。

关于laravel - 在 laravel-passport-social-grant 包上获取 invalid_credentials,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61045228/

相关文章:

javascript - 使用 ThreeJS 可以保护 3D 模型吗?

python - 求解一对线性方程时的断言错误

javascript - 按下后退按钮时防止 react 路由器重新加载 API 调用。 react

python - 无法执行 Cloud Function 触发不允许未经身份验证的调用的 HTTP

go - 在 Ubuntu 18.04 的 $ANDROID_HOME/ndk-bundle 和 $

python - 在 Django Channels 上找不到路径

javascript - 使用 Jest/Enzyme 在 React 中的功能组件内部测试方法

javascript - 使用 Javascript 在带有自定义磁贴的新浏览器选项卡中打开 PDF

magento - 有没有办法使用 Rest api 在 Magento 2 中获取特定类别的自定义

python - Pygame,声音不播放