0

我正在遵循的步骤。

  1. 我将身份验证参数作为 1 发送到 public.php 文件并接收 oauth_token 和 oauth_token_secret。

http://localhost/XeroOAuth-PHP-master/public.php?authenticate=1

在此阶段,会话生成如下

数组([oauth] => 数组([oauth_token] => XXX [oauth_token_secret] => XXX [oauth_callback_confirmed] => true )

)

  1. 下一步,我调用这个网址http://localhost/XeroOAuth-PHP-master/public.php?oauth_verifier=1&oauth_token=3CHDO7HFISTMVJXDX7IIPMRJUZH2FC

在这个阶段,它会抛出以下错误,即 permission_denied。

错误:oauth_problem=permission_denied&oauth_problem_advice=%20consumer%20was%20denied%20access%20to%20this%20resource。

以下是我在页面中收到的整个错误格式。

XeroOAuth 对象 ( [_xero_defaults] => 数组 ( [xero_url] => https://api.xero.com/ [site] => https://api.xero.com [authorize_url] => https://api. xero.com/oauth/Authorize [signature_method] => HMAC-SHA1)

[_xero_consumer_options] => Array
    (
        [request_token_path] => oauth/RequestToken
        [access_token_path] => oauth/AccessToken
        [authorize_path] => oauth/Authorize
    )

[_action] => 
[_nonce_chars] => 
[params] => Array
    (
    )

[headers] => Array
    (
        [Accept] => application/xml
        [Content-Length] => 0
        [Expect] => 
    )

[auto_fixed_time] => 
[buffer] => 
[request_params] => Array
    (
    )

[_xero_curl_options] => Array
    (
        [curl_connecttimeout] => 30
        [curl_timeout] => 20
        [curl_ssl_verifypeer] => 2
        [curl_cainfo] => C:\xampp\htdocs\XeroOAuth-PHP-master/certs/ca-bundle.crt
        [curl_followlocation] => 
        [curl_ssl_verifyhost] => 2
        [curl_proxy] => 
        [curl_proxyuserpwd] => 
        [curl_encoding] => 
        [curl_verbose] => 1
    )

[config] => Array
    (
        [xero_url] => https://api.xero.com/
        [site] => https://api.xero.com
        [authorize_url] => https://api.xero.com/oauth/Authorize
        [signature_method] => HMAC-SHA1
        [request_token_path] => oauth/RequestToken
        [access_token_path] => oauth/AccessToken
        [authorize_path] => oauth/Authorize
        [curl_connecttimeout] => 30
        [curl_timeout] => 20
        [curl_ssl_verifypeer] => 2
        [curl_cainfo] => C:\xampp\htdocs\XeroOAuth-PHP-master/certs/ca-bundle.crt
        [curl_followlocation] => 
        [curl_ssl_verifyhost] => 2
        [curl_proxy] => 
        [curl_proxyuserpwd] => 
        [curl_encoding] => 
        [curl_verbose] => 1
        [application_type] => Public
        [oauth_callback] => localhost
        [user_agent] => Xero-OAuth-PHP Public
        [consumer_key] => XXX
        [shared_secret] => XXX
        [core_version] => 2.0
        [payroll_version] => 1.0
        [file_version] => 1.0
        [access_token] => XXX
        [access_token_secret] => XXX
        [host] => https://api.xero.com/oauth/
        [multipart] => 
    )

[method] => GET
[url] => https://api.xero.com/oauth/AccessToken
[sign] => Array
    (
        [parameters] => Array
            (
                [oauth_consumer_key] => YDOVURHNHW7RIHJ384ZYJ7TMVQT8W7
                [oauth_nonce] => Ubrb
                [oauth_signature_method] => HMAC-SHA1
                [oauth_timestamp] => 1504002299
                [oauth_token] => 3CHDO7HFISTMVJXDX7IIPMRJUZH2FC
                [oauth_verifier] => 1
                [oauth_version] => 1.0
                [oauth_signature] => o9ucXeTTvA04tQgLTBX5AuMoX2Y=
            )

        [signature] => o9ucXeTTvA04tQgLTBX5AuMoX2Y%3D
        [signed_url] => https://api.xero.com/oauth/AccessToken?oauth_consumer_key=YDOVURHNHW7RIHJ384ZYJ7TMVQT8W7&oauth_nonce=Ubrb&oauth_signature=o9ucXeTTvA04tQgLTBX5AuMoX2Y%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1504002299&oauth_token=3CHDO7HFISTMVJXDX7IIPMRJUZH2FC&oauth_verifier=1&oauth_version=1.0
        [header] => OAuth oauth_consumer_key="YDOVURHNHW7RIHJ384ZYJ7TMVQT8W7", oauth_nonce="Ubrb", oauth_signature="o9ucXeTTvA04tQgLTBX5AuMoX2Y%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1504002299", oauth_token="3CHDO7HFISTMVJXDX7IIPMRJUZH2FC", oauth_verifier="1", oauth_version="1.0"
        [sbs] => GET&https%3A%2F%2Fapi.xero.com%2Foauth%2FAccessToken&oauth_consumer_key%3DYDOVURHNHW7RIHJ384ZYJ7TMVQT8W7%26oauth_nonce%3DUbrb%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1504002299%26oauth_token%3D3CHDO7HFISTMVJXDX7IIPMRJUZH2FC%26oauth_verifier%3D1%26oauth_version%3D1.0
    )

[format] => xml
[response] => Array
    (
        [headers] => Array
            (
                [cache_control] => private
                [content_type] => text/html; charset=utf-8
                [date] => Tue, 29 Aug 2017 10:25:01 GMT
                [strict_transport_security] => max-age=31536000
                [www_authenticate] => OAuth Realm="10.144.115.64"
                [content_length] => 115
                [connection] => keep-alive
            )

        [code] => 401
        [response] => oauth_problem=permission_denied&oauth_problem_advice=The%20consumer%20was%20denied%20access%20to%20this%20resource.
        [info] => Array
            (
                [url] => https://api.xero.com/oauth/AccessToken?oauth_consumer_key=YDOVURHNHW7RIHJ384ZYJ7TMVQT8W7&oauth_nonce=Ubrb&oauth_signature=o9ucXeTTvA04tQgLTBX5AuMoX2Y%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1504002299&oauth_token=3CHDO7HFISTMVJXDX7IIPMRJUZH2FC&oauth_verifier=1&oauth_version=1.0
                [content_type] => text/html; charset=utf-8
                [http_code] => 401
                [header_size] => 267
                [request_size] => 418
                [filetime] => -1
                [ssl_verify_result] => 0
                [redirect_count] => 0
                [total_time] => 1.438
                [namelookup_time] => 0
                [connect_time] => 0.328
                [pretransfer_time] => 1.016
                [size_upload] => 0
                [size_download] => 115
                [speed_download] => 79
                [speed_upload] => 0
                [download_content_length] => 115
                [upload_content_length] => -1
                [starttransfer_time] => 1.438
                [redirect_time] => 0
                [redirect_url] => 
                [primary_ip] => 54.209.35.242
                [certinfo] => Array
                    (
                    )

                [primary_port] => 443
                [local_ip] => 192.168.1.35
                [local_port] => 60675
                [request_header] => GET /oauth/AccessToken?oauth_consumer_key=YDOVURHNHW7RIHJ384ZYJ7TMVQT8W7&oauth_nonce=Ubrb&oauth_signature=o9ucXeTTvA04tQgLTBX5AuMoX2Y%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1504002299&oauth_token=3CHDO7HFISTMVJXDX7IIPMRJUZH2FC&oauth_verifier=1&oauth_version=1.0 HTTP/1.1

主机:api.xero.com 用户代理:Xero-OAuth-PHP 公共接受编码:放气,gzip 接受:应用程序/xml 内容长度:0

            )

        [format] => xml
    )

)

4

1 回答 1

0

如果您在访问令牌尚未获得组织授权的情况下尝试将请求令牌换成访问令牌,则会返回此错误。

您的应用程序流程中应该有一个步骤将用户重定向到 https://api.xero.com/oauth/Authorize?oauth_token=[OAUTH_TOKEN_HERE] - 一旦 Xero 用户选择了他们授予访问权限的组织如果没问题,你的第二个电话应该可以工作。

于 2017-12-20T20:53:00.990 回答