asp.net web api - In Web Api / Owin architecture, where are requests to '/token' handled? -


I am trying to understand asp.net web API personal accounts authentication and authorization. I have to see a lot of tutorials on the web. In a nutshell, when a user provides the username and password, the API raises the issue of a token that the customer will use it in the post-API call to identify himself. The token is received by a request to the user agent, usually: It appears that the path is set in the startup class:

  tokenend pointpoint = new pathstring ("/ token")   

My problem is, can not I find any controller methods that match that path How does this work?

When you create a new project in ASP.NET with personal authentication, the solution is to handle the authentication request Has been created with an OAuth provider.

If you look at the solution, then you should see a provider folder with a class ApplicationOAuthProvider.

This class applies all the arguments. Authenticate your website to the website configuration is set to startup so that you can customize the URL endpoint through the othe Open. New PathString ("/ Token"), Provider = New ApplicationOAuthProvider (PublicClientId), AuthorizePointPoint = New PathString ("/ API / Account / ExtroLogin"), New PathString ("/ API / Account / ExtroLogin"), AccessTokenExSiper Times SAP = Timespan Formidable (14), permissionswith htt = true};

The tokenspoint path properties, defining the URL, will be removed from the granterosourceoner credentials method of GrandResource Owner credentials.

If you use intelligence to authenticate and use such a body, grant_type = password and user name = testUserName and password = TestPassword

You should specify the following method:

  Public override async work grant resource resource maker (OAuthGrantResourceOwnerCredentialsContext reference) {var userManager = context.OwinContext.GetUserManager & lt; ApplicationUserManager & gt; (); ApplicationUser User = Find User Manager FindAsync (context.UserName, context.Password); If (user == tap) {context.SetError ("invalid_grant", "username or password is incorrect."); Return; } Claims oAuthIdentity = Wait for the user. GenerateUserIdentityAsync (User Manager, OAuthDefaults.AuthenticationType); Contingency cookies command = waiting for the user GenerateUserIdentityAynync (User Manager, CookieEditification Default. AuthenticationType); Authentication properties property = create properties (user.UserName); Authentication Ticket Ticket = New Authentication Tate (oAuthIdentity, Properties); Context.Validated (ticket); context.Request.Context.Authentication.SignIn (cookiesIdentity); }   

where the context.UserName and context.Password is set with the data used in the request. After confirmation of identity (here the unit framework and a couple username, using a password in a database), a beer token to the caller is sent. This bearer token can be used to authenticate for other calls.

Regards.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -