【发布时间】:2021-01-19 11:52:08
【问题描述】:
我需要将该 curl 请求转换为 c#。我正在使用 RestSharp。卷曲请求:
> curl -X POST -i https://gw.api.alphabank.eu/sandbox/auth/token \
-u "{{client_id}}:{{client_secret}}" \
-d "grant_type=client_credentials&scope=account-info-setup"
我尝试了以下代码,但最终得到了“invalid_grant”错误作为响应。 任何想法我做错了什么?
我的代码:
var client = new RestClient(url);
var request = new RestRequest();
request.Method = Method.POST;
client.Authenticator = new HttpBasicAuthenticator(ABclientID, ABclientSecret);
request.AddParameter("grant_type", "client_credentials");
request.AddParameter("scope", "account-info-setup");
request.OnBeforeDeserialization = resp => { resp.ContentType = "application/x-www-form-urlencoded"; };
IRestResponse response = client.Execute(request);
【问题讨论】: