我正在尝试通过 TinyOauth 1.0a .NET程序包进行发帖,但是我总是得到 invalid_oauth签名。我正在使用 RestClient(RestSharp)进行邮递,尽管在邮递员中工作正常。 谁能帮助我如何通过Rest.Sharp客户端和.NET中的tinyOauth进行发帖?
Request:
{
"cardNumber": "199990713879999",
"storeId": "12",
"pin": "458920"
}
答案 0 :(得分:0)
注意:您需要通过nuget数据包管理器在项目中添加RestSharp和TinyOauth1.0进行呼叫
public async Task<string> httpCalls(string url, bool isGet, string data)
{
String responseJson = String.Empty;
AccessTokenInfo accessTokenInfo = await OAuth();
TinyOAuth tinyOAuth = new TinyOAuth(oauthConfig());
RestClient client = new RestClient(url);
RestRequest request;
if (isGet == true)
{
request = new RestRequest(Method.GET);
request.AddHeader("Authorization", tinyOAuth.GetAuthorizationHeader(accessTokenInfo.AccessToken, accessTokenInfo.AccessTokenSecret, url, HttpMethod.Get).ToString());
}
else
{
request = new RestRequest(Method.POST);
request.AddHeader("Authorization", tinyOAuth.GetAuthorizationHeader(accessTokenInfo.AccessToken, accessTokenInfo.AccessTokenSecret, url, HttpMethod.Post).ToString());
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", data, ParameterType.RequestBody);
}
IRestResponse response = client.Execute(request);
return response.Content;
}