我刚刚完成了Oauth2流程,它工作得很完美。我正在使用官方的PHP库,但我不能让我的cron作业更新令牌。
我收到这个错误:* 未捕获异常“BadMethodCallException”,消息为“未传递必需参数:“refresh_token”* 当我尝试刷新时。
代码如下。
ini_set('display_errors', 'On');
require '../../vendor/autoload.php';
include '../config.php';
// Use this class to deserialize error caught
use XeroAPI\XeroPHP\AccountingObjectSerializer;
$accessToken = "**********"
$refreshToken = "**********"
$realID = "**********"
$xeroTenantId = (string)$realID;
$provider = new \League\OAuth2\Client\Provider\GenericProvider([
'clientId' => '********************************',
'clientSecret' => '******************************************',
'refresh_token' => $refreshToken,
'urlAuthorize' => 'https://login.xero.com/identity/connect/authorize',
'urlAccessToken' => 'https://identity.xero.com/connect/token',
'urlResourceOwnerDetails' => 'https://identity.xero.com/resources'
]);
$newAccessToken = $provider->getAccessToken('refresh_token', [
'refresh_token' => $refreshToken
]);
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( (string)$refreshToken );
$accountingApi = new XeroAPI\XeroPHP\Api\AccountingApi(
new GuzzleHttp\Client(),
$config
);
$assetApi = new XeroAPI\XeroPHP\Api\AssetApi(
new GuzzleHttp\Client(),
$config
);
$identityApi = new XeroAPI\XeroPHP\Api\IdentityApi(
new GuzzleHttp\Client(),
$config
);
$projectApi = new XeroAPI\XeroPHP\Api\ProjectApi(
new GuzzleHttp\Client(),
$config
);
有没有人能看出我错过了什么?
1条答案
按热度按时间bvjveswy1#
错误代码,应该是: