简体   繁体   中英

400 (Bad Request) when I request a token

I have written the following code to connect and retrieve a token from the Autodesk . but this does not work properly:

var client = new RestClient("https://accounts.autodesk.com");
client.Authenticator = OAuth1Authenticator.ForRequestToken(consumerKey, consumerSecret);
var request = new RestRequest("OAuth/RequestToken", Method.POST);
var response = await _client.Execute(request);

Executing the request it throws a bad request exception.

Response status code does not indicate success: 400 (Bad Request).

For consumerKey and consumerSecret I respectively used my email and the associated password that I've already registered in accounts.autodesk.com

How can I understand if I'm sending the request in a wrong format or I just send a wrong consumerKey and consumerSecret . And If they are wrong could you please guide me where I can obtain these parameters from Autodesk?

It's not at all your email and password that you need to use but API keys that are generated from your account on our developer portal.

Please sign up or login to the portal: https://developer.autodesk.com/ And follow the step by step tutorial in order to request a token, there are detailed explanations of the workflow there, it can't be easier than that: https://developer.autodesk.com/en/docs/oauth/v2/tutorials .

I have created a C# sample and a lib but it hasn't been updated yet to use scopes, you can take a look at the discussion in the issues: https://github.com/Developer-Autodesk/view.and.data-dotnet-wpf.tutorial

Finally we are working on generated wrappers for our REST API's so we will be able to produce more stable samples pretty soon. Check out our blog for upcoming news about that: http://adndevblog.typepad.com/cloud_and_mobile

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM