Skip to main content

Posts

Showing posts from September, 2019

Posting Username and Password to Identity Server 4 to get a Token

A small and simple task, but which took me a lot of time searching the web. So now I know where to find it. Disclaimer we will be using the Password Grant Flow you can find details here , in the link its discouraged to use this flow except maybe on legacy applications. That aside. Identity Server 4 Set up you identity server to use the password grant as indicated in their documentation, you can find link here  . C# Code  var client = new HttpClient();             client.BaseAddress = new Uri("http://localhost:5000");             var byteArray = Encoding.Default.GetBytes("ro.client:secret");             client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));             var request = new HttpRequestMessage(HttpMethod.Post, "/connect/token");   ...