我已经在 Bronto 沙箱中设置了 Hallmonitor(符合 OAuth 2.0 的服务),但是使用 RestSharp 我无法获取访问令牌以进一步调用 REST API。
我已经能够成功使用 curl 即
curl -X POST -d "grant_type=client_credentials&client_id=CLIENTID&client_secret=CLIENTSECRET" https://auth.bronto.com/oauth2/token
我尝试了以下代码的多种变体,但似乎没有任何效果,我总是收到错误响应。
{
"error_description": "Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method).",
"error": "unauthorized_client"
}
简化的示例代码
var client = new RestClient("https://auth.bronto.com");
client.Authenticator = new HttpBasicAuthenticator(clientId, secret);
//client.Authenticator = new SimpleAuthenticator(CLIENT_ID, clientId, CLIENT_SECRET, secret);
RestRequest request = new RestRequest("/oauth2/token", Method.POST);
//request.AddHeader("Authorization", "Basic " + client);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter(GRANT_TYPE, CLIENT_CREDENTIALS);
//request.AddParameter(CLIENT_ID, clientId);
//request.AddParameter(CLIENT_SECRET, secret);
request.RequestFormat = DataFormat.Json;
IRestResponse response = client.Execute(request);
有没有人使用带有 Bronto REST API 的 RestSharp 来成功验证并获取访问令牌?
任何帮助深表感谢。