- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我使用的库 https://github.com/php-twinfield/
当我调用 Oauth 登录时,这是一个问题。我已经完成了几乎带有用户名和密码的 API,但客户希望它带有 Oauth。我认为redirectUri 有问题。当我调用 Oauth 时,它总是显示:
{
"success": false,
"error": "invalid_grant"
}
clientId : Demorent
clientSecret : /iY7gyWn3Hkdgs4XzUG66SDyPNkk177x3A==
redirectUri : https://www.oauth.client.redirect.uri.com
public function login(\Illuminate\Http\Request $request)
{
try {
// In the $request param all the credential given
$provider = new \PhpTwinfield\Secure\Provider\OAuthProvider([
'clientId' => $request->clientId,
'clientSecret' => $request->clientSecret,
'redirectUri' => $request->redirectUri
]);
// Here pass the authorization code
$accessToken = $provider->getAccessToken("authorization_code", ["code" =>'NLA000067']);
$refreshToken = $accessToken->getRefreshToken();
$office = \PhpTwinfield\Office::fromCode("1008");
$connection = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $refreshToken, $office);
$customerApiConnector = new \PhpTwinfield\ApiConnectors\CustomerApiConnector($connection);
$result = $customerApiConnector->get('1008',$office);
$jsonResponse = JsonResponse::success($result);
} catch(SoapFault $e) {
$jsonResponse = empty($e->getMessage()) ? JsonResponse::error(class_basename($e)) : JsonResponse::error($e->getMessage());
}
return $jsonResponse;
}
最佳答案
开始,invalid_grant
是标准的 OAuth 2.0 错误参数。由于 OpenID Connect 是基于 OAuth 2.0 构建的,因此接收此响应是有效的。如果您查看 5.2 Error Response section ,你会发现下面的解释
invalid_grant
The provided authorization grant (e.g., authorizationcode, resource owner credentials) or refresh token isinvalid, expired, revoked, does not match the redirectionURI used in the authorization request, or was issued toanother client.
// Here pass the authorization code
$accessToken = $provider->getAccessToken("authorization_code", ["code" =>'NLA000067']);
您是否使用硬编码
授权码 (NLA000067) ?这是错误的。授权码授权的第一步是获取授权码。然后只有您可以执行 token 请求。您从授权请求中获取授权代码,但我没有看到您正在这样做。
invalid_grant
是由无效的授权码引起的。
关于php - "Invalid_grant"使用 Twinfield Openid Oauth 连接时的响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50794466/
这是我使用的库 https://github.com/php-twinfield/ 当我调用 Oauth 登录时,这是一个问题。我已经完成了几乎带有用户名和密码的 API,但客户希望它带有 Oauth
我正在尝试连接 Twinfield logon api通过Java。我试过的代码是 import java.net.URL; import javax.xml.namespace.QName; imp
我是一名优秀的程序员,十分优秀!