我正在使用 oauth 1.0,直到现在我可以成功地从 Google 获取访问令牌。但是当我想从https://www.google.com/m8/feeds/contacts/default/full检索用户联系人时,它返回 401 错误并且没有进一步的解释。
我发现 Google Playground 中的信息可能并不准确,例如第 3 步和第 5 步中的签名基本字符串包含 oauth_version 但它是错误的。(如果包含 oauth_version,它将返回 signature_invalid 并且不包含 oauth_version)
这是我的要求:
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sbGetContacts.ToString());
req.Method = "GET";
req.Headers.Add(authHeader);
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
这是我的标题:
string authHeader = "Authorization: OAuth " +
"oauth_version=" + "\"" + "1.0" + "\"" + "\"," +
"oauth_nonce=" + "\"" + nonce + "\"," +
"oauth_timestamp=" + "\"" + timeStamp + "\"," +
"oauth_consumer_key=" + "\"" + GoogleconsumerKey + "\"," +
"oauth_token=" + "\"" + OauthToken+ "\"," +
"oauth_signature_method=" + "\"" + "HMAC-SHA1" + "\"," +
"oauth_signature=" + "\"" + UpperCaseUrlEncode(sig) + "\"";
谁能告诉我如何解决这个问题?