我有这个问题,通常api入口点工作良好:
https://www.google.com/analytics/feeds/accounts/default但是当我添加如下参数:
https://www.google.com/analytics/feeds/accounts/default?max-results=50则失败。这是交互的一部分,如果有人能指出哪里出错了:
GET&https%3A%2F%2Fwww.google.com%2Fanalytics%2Ffeeds%2Faccounts%2Fdefault&oauth_consumer_key%3DCONSUMERKEY%26oauth_nonce%3D88526211463343710%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1321044173%26oauth_token%3DCONSUMERTOKEN%26oauth_version%3D1.0
{ host: 'www.google.com',
path: '/analytics/feeds/accounts/default?max-results=25',
method: 'GET',
headers: { Authorization: 'OAuth oauth_token="CONSUMERTOKEN", oauth_timestamp="1321044173", oauth_nonce="88526211463343710", oauth_consumer_key="CONSUMERKEY", oauth_signature_method="HMAC-SHA1", oauth_version="1.0", oauth_signature="S%2Bob3FyVFpwRsu4x7C%2FwmkwbnDY%3D"' } }
STATUS: 401
HEADERS: {"www-authenticate":"GoogleLogin realm="http://www.google.com/accounts/ClientLogin", service="analytics"","content-type":"text/html; charset=UTF-8","date":"Fri, 11 Nov 2011 20:42:56 GMT","expires":"Fri, 11 Nov 2011 20:42:56 GMT","cache-control":"private, max-age=0","x-content-type-options":"nosniff","x-frame-options":"SAMEORIGIN","x-xss-protection":"1; mode=block","server":"GSE","connection":"close"}
response: Unknown authorization header
这个问题在这里和那里以不同的方式被问了几次,但我到目前为止还没有找到解决的根本问题…
事实证明,Google在签名基字符串上需要url参数:
GET& https % 3 % 2 f % 2 fwww.google.com % 2 fanalytics % 2 ffeeds % 2 faccounts % 2 fdefault& oauth_consumer_key % 3 dconsumerkey % 26 oauth_nonce % 3 d88526211463343710 % 26 oauth_signature_method % 3 dhmac-sha1 % 26 oauth_timestamp % 3 d1321044173 % 26 oauth_token % 3 dconsumertoken % 26 oauth_version % 3 d1.0
->
GET& https % 3 % 2 f % 2 fwww.google.com % 2 fanalytics % 2 ffeeds % 2 faccounts % 2 fdefault& oauth_consumer_key % 3 dconsumerkey % 26 oauth_nonce % 3 d88526211463343710 % 26 oauth_signature_method % 3 dhmac-sha1 % 26 oauth_timestamp % 3 d1321044173 % 26 oauth_token % 3 dconsumertoken % 26 oauth_version % 3 d1.0&效果= 50
按字母顺序排列,其他参数也应该按字母顺序排列。