Я работаю в .NET 4.6.2 и у меня возникли проблемы с привязкой при попытке обратиться к библиотеке Square.Connect, которая является стандартной версией 2.0, поэтому я пытаюсь вручную кодировать вещи.
public ActionResult RequestToken(string code)
{
if (!string.IsNullOrEmpty(code))
{
string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/";
SquareUpRequest squareUpRequest = new SquareUpRequest()
{
client_id = "Application ID (Not sandbox)",
client_secret = "Personal Access Token",
code = code
};
var client = new RestSharp.RestClient(baseUrl);
var request = new RestSharp.RestRequest("https://connect.squareup.com/oauth/token", RestSharp.Method.POST);
request.RequestFormat = RestSharp.DataFormat.Json;
request.AddBody(squareUpRequest);
request.AddHeader("Authorization", "Client OAuthApplicationSecret");
var response = client.Execute(request);
}
return View();
}
Я предполагаю, что могу запросить токен много раз.SquareUpRequest - это пользовательский класс.
Вы видели что-то неправильное?