oauth 2.0 - How to get Token from DotNetOpenAuth OAuthAuthorizationServer sample with C#? -


how token dotnetopenauth oauthauthorizationserver sample c#? i'm running sample provided in github. want token, unsuccessfull. 400, bad request. request i've sending follows:

var request = webrequest.createhttp("http://localhost:50172/oauth/token");         request.method = "post";         request.contentlength = 0;         request.headers.add("client_id", "sampleconsumer");         request.headers.add("client_secret", "samplesecret");         request.headers.add("grant_type", "authorization_code");         request.headers.add("code", "teste");         request.headers.add("redirect_uri", "");          webresponse response = null;          try         {             response = request.getresponse();         }         catch (exception ex)         {             //400 -  bad request here.         } 

i have no skills oauth, first attempt. i've searched lot still bit confuse.

do not use headers clientid , other stuff, put body.

this how token client credential grant:

using newtonsoft.json;  ... var url = "http://localhost:50172/oauth/token" var request = webrequest.create(url); request.method = "post";  string data = "grant_type=client_credentials&client_id=" +     "sampleconsumer&client_secret=samplesecret"; request.contenttype = "application/x-www-form-urlencoded"; byte[] datastream = encoding.utf8.getbytes(data); request.contentlength = datastream.length; stream newstream = request.getrequeststream();  newstream.write(datastream, 0, datastream.length); newstream.close();  webresponse response = request.getresponse(); using (var reader = new streamreader(response.getresponsestream())) {     string result = reader.readtoend();     accesstoken = jsonconvert.deserializeobject<accesstoken>(result); } 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -