我在使用xero api刷新令牌时遇到问题。当我第一次创建令牌时,一切都很好。刷新令牌时,身份验证失败。
{"Type":null,"Title":"Forbidden","Status":403,"Detail":"AuthenticationUnsuccessful","Instance":"8d6256e5-3376-4960-be52-cf8b22ee241c","Extensions":{}}
我的代码如下:
public function refreshToken()
{
$provider = new GenericProvider([
'clientId' => $valuestore->get('client_id'),
'clientSecret' => $valuestore->get('client_secret'),
'redirectUri' => $valuestore->get('callback_url'),
'urlAuthorize' => 'https://login.xero.com/identity/connect/authorize',
'urlAccessToken' => 'https://identity.xero.com/connect/token',
'urlResourceOwnerDetails' => 'https://api.xero.com/api.xro/2.0/Organisation'
]);
$newAccessToken = $provider->getAccessToken('refresh_token', [
'refresh_token' => $this->getRefreshToken()
]);
// Save my token, expiration and refresh token
$this->setOauth($newAccessToken);
}
public function setOauth($accessToken)
{
$oauth2 = [
'token' => $accessToken->getToken(),
'expires' => $accessToken->getExpires(),
'tenant_id' => $this->getTenantId(),
'refresh_token' => $accessToken->getRefreshToken(),
'id_token' => $accessToken->getValues()["id_token"]
];
//set session
}
预先感谢
问候 丹尼