Thinktecture IdentityModel getting session token

416 views Asked by At

The way to get a session token using the Thinktecture IdentityModel is http://www.website.com/api/token. But I am getting and error "Response status code does not indicate success: 404 (Not Found)." when using the browser as well as the following code.

var credentials = new NetworkCredential("admin", "password");
var handler = new HttpClientHandler { Credentials = credentials };
var client = new HttpClient(handler) {BaseAddress = new Uri("http://www.website.com/")};

var response = await client.GetAsync("api/token");
response.EnsureSuccessStatusCode(); // Throw on error code.
var accountInformationJson = await response.Content.ReadAsStringAsync();

However when I try this using CURL curl --user admin:password --get http://www.website.com/api/token

I seem to be getting back the session json fine { "access_token": "hfsdhfhfjhdfhds8f9jsdhr9843hrf.shf789qy34rjhf9awyfw8ehf.....", "expires_in": 36000.0 }

Any ideas why this would happen?

1

There are 1 answers

0
sunil On BEST ANSWER

I had to call http://www.website.com/api/controller/token to get session token.