Using Identity in an Asp.Net MVC 5 application with Web Api and vice versa

Asked

Viewed 285 times

2

When I create a project Asp.Net MVC with Individual User Accounts i can get into the application this way:

var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);

But I need to provide login access for mobile apps that way:

link: http://localhost:51836/token  
header: content-type: application/x-www-form-urlencoded  
body: [email protected]&password=123456&grant_type=password  

How do I keep logging in this way and also make available Web Api(in the same project Asp.Net MVC) for mobile devices to log in and receive Token access to access the pages Web Api that I have in the application Asp.Net MVC?

1 answer

1

I would do an Action (anonymity) the part for the mobile app login.

So in this action I would search for the user and then call the code you posted.

Sack ?

Create an Action and a controller that can be accessed without authenticating

in this action, search the user, and if successful call

var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);

After that the rest of the application need not worry where it came from

Browser other questions tagged

You are not signed in. Login or sign up in order to post.