我正在使用Oauth 1.0进行身份验证过程。我被困在获取请求令牌的第一步。执行以下请求将抛出'远程服务器返回错误:(401)未经授权。'
Uri uri1 = new Uri("https://api.500px.com/v1/oauth/request_token");
string consumerKey = "ABFHGHIQYW4clmuXXXXXXXBy528gl2zEEEEN";
string consumerSecret = "BBGHGJnrJaKKjoScCFHJGJFKK6HVjjDHFJSDJDjno";
string timeStamp = myOAuth.GenerateTimeStamp();
string nonce = myOAuth.GenerateNonce();
myOAuth.includeVersion = true;
string signature = myOAuth.GenerateSignature(uri1, consumerKey, consumerSecret, "", "", "POST", timeStamp, nonce, OAuth.OAuthBase.SignatureTypes.HMACSHA1, out normalizedUrl, out normalizedRequestParameters);
request = (HttpWebRequest)WebRequest.Create("https://api.500px.com/v1/oauth/request_token");
request.Method = "POST";
request.KeepAlive = true;
request.UseDefaultCredentials = true;
request.Credentials = CredentialCache.DefaultCredentials;
request.Headers.Add("Authorization", "OAuth oauth_callback=\"http://www.abcxyz.com\",oauth_consumer_key=\"" +consumerKey + "\",oauth_nonce=\"" +nonce + "\",oauth_signature_method=\"HMAC-SHA1\",oauth_timestamp=\"" + timeStamp + "\", oauth_version=\"1.0\",oauth_signature=" + signature);
response = (HttpWebResponse)request.GetResponse();
所有参数都通过'授权标题' HTTP Post。我肯定在我的请求中遗漏了一些东西,但无法弄清楚究竟缺少什么。
任何指针或任何形式的帮助都将受到高度赞赏。非常感谢。
答案 0 :(得分:0)
首先需要获取令牌的请求。之后创建另一个请求并将令牌作为参数传递。