获取401未经授权的Xero oAuth 2.0-

时间:2020-09-30 14:47:13

标签: php laravel oauth-2.0 xero-api

我正在尝试使用Xero oAuth 2.0创建新联系人并出现此错误:

[<ZipInfo filename='XLFile-Demo.xlsx' compress_type=deflate external_attr=0x20 file_size=31964 compress_size=29340>]

我的作用域为:

[401] Client error: `PUT https://api.xero.com/api.xro/2.0/Contacts?summarizeErrors=true` resulted in a `401 Unauthorized` response: 

我能够连接到Xero(using this code),并且收到消息该应用程序已连接到Xero ,但是当我使用以下代码时:-

'scopes'   => [
            'openid',
            'email',
            'profile',
            'offline_access',
            'accounting.settings',
            'accounting.contacts',
            'accounting.reports.read',
        ],

错误: [401]客户端错误:public function xeroTest(OauthCredentialManager $xeroCredentials) { $apiInstance = resolve(\XeroAPI\XeroPHP\Api\AccountingApi::class); $contact = resolve( \XeroAPI\XeroPHP\Models\Accounting\Contact::class); $contact->setName('Abcdef'); $contact->setContactId('6d42f03b-181f-43e3-93fb-2025c0hjhe92'); $apiResponse = $apiInstance->createContacts($xeroCredentials->getTenantId() ,$contact,true); $message = 'New Contact Name: ' . $apiResponse->getContacts()[0]->getName(); return $message; } 导致PUT https://api.xero.com/api.xro/2.0/Contacts?summarizeErrors=true响应:

1 个答案:

答案 0 :(得分:0)

我看不到您的所有代码,但您可能只需要在PHP客户端上设置有效的 access_token

https://github.com/XeroAPI/xero-php-oauth2#callbackphp

相关问题