Question

Does anyone know of a sample Application demonstrating best practices to use ThinkTecture IdentityServer v2 from a desktop Application like WPF?

Is using a HttpClient to Call the AccountController's Signin operation the preferred way?

I'm trying to do something like this, but the response I get is the HTML page which a webapplication would be redirected to to sign in.

    private async Task LoginRequest(string username, string password)
    {
        HttpClient client = new HttpClient();
        client.DefaultRequestHeaders.Add("accept", "application/json");
        client.BaseAddress = new Uri(@"https://<server-name>/Idsrv-sample/");
        var loginData = new SignInModel { UserName = username, Password = password, IsSigninRequest = true };            
        var signinResponse = await client.PutAsJsonAsync("account/signin", loginData);
        var result = await signinResponse.Content.ReadAsStringAsync();
        MessageBox.Show(result);  // The IdentityServer login page
    }
Was it helpful?

Solution

Not sure what you mean with "best practices" - but IdentityServer supports OAuth2 to get authorization tokens for your backend:

http://leastprivilege.com/2012/11/01/oauth2-in-thinktecture-identityserver-v2-resource-owner-password-flow/

see also here: https://github.com/thinktecture/Thinktecture.IdentityServer.v2/wiki

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top