Laravel Passport 无效刷新令牌 - 令牌未链接到客户端

Laravel Passport invalid refresh token - token is not linked to client

我在 Laravel 5.5 上使用 Passport,尝试刷新访问令牌时收到错误 - 仅在生产服务器上 - 本地开发环境工作正常!

这是返回的错误:

{
"error": "invalid_request",
"message": "The refresh token is invalid.",
"hint": "Token is not linked to client"
}

我已验证令牌和客户端存在于数据库中、未过期、未被撤销、存储正确等。

因为系统是一个多租户系统(每个租户都有自己的数据库)我没有使用命令创建护照客户端

php artisan passport:client

相反,我复制了护照 oauth_clients table 和每个租户的内容 - 这样每个租户都使用相同的客户端凭据,例如从前端登录,从应用程序登录(但使用不同的端点)。

我不知道为什么它在我的本地机器上运行良好,但在生产环境中却不行。

有谁知道 php artisan passport:client 除了在 oauth_clients table 中创建一行之外到底做了什么?

我在想,也许需要的不仅仅是复制 oauth_clients table 内容..

感谢任何建议!谢谢

在深入了解供应商代码后,我通过修改

解决了问题

vendor/league/oauth2-server/src/Grant/RefreshTokenGrant.php

函数验证旧刷新令牌

已更改

if ($refreshTokenData['client_id'] !== $clientId) {
        $this->getEmitter()->emit(new RequestEvent(RequestEvent::REFRESH_TOKEN_CLIENT_FAILED, $request));
        throw OAuthServerException::invalidRefreshToken('Token is not linked to client');
    }

if ($refreshTokenData['client_id'] != $clientId) {
        $this->getEmitter()->emit(new RequestEvent(RequestEvent::REFRESH_TOKEN_CLIENT_FAILED, $request));
        throw OAuthServerException::invalidRefreshToken('Token is not linked to client');
    }

即使 $clientId 匹配,函数也会传递一个字符串(根据需要),但 $refreshTokenData['client_id'] 是一个整数。

fml.