Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
310 views
in Technique[技术] by (71.8m points)

asp.net core - IdentityServer login without web interaction

I'm currently writing a Xamarin application and I wish to login to my app, this one use IdentityServer 4 for auth.

I wish to avoid any "web" interface for the email/password login, but I'm not sure how to do this (If possible).

So, for now I have a controller with a method like this:

public void LoginAsync(string cliendId, string clientSecret, string email, string password)
{
    // Check the clientId & secrets match
    ....

    // Sign in the user
    var result = await SignInManager.PasswordSignInAsync(email, password, false, true);

    // How to return a token to the Xamarin client here?
}

So, I have 2 questions please:

  • first I directly check the clientId & secret, is it the way to go? Or should I get a token, then protect this API, and then access it with the token.
  • how can I generate a new token for the Xamarin client to access the other APIs?

Thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Using OpenID Connect you are supposed to open a new web interface and let the user login through that page. Creating your own login/password form is a bad for many reasons. One is that the user does not now where his credentials will end up. Your application should never touch or see the users username/password.

If there is no user involved, then you can look at using the client credentials flow that is supported by IdentityServer.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...