ASP Identity and Owin - Token Generation

I have the following:

OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions() { AllowInsecureHttp = true, TokenEndpointPath = new PathString("/token"), AccessTokenExpireTimeSpan = TimeSpan.FromDays(1), Provider = new SimpleAuthorizationServerProvider(), }; 

Everything works fine, I need to call / token with request body arguments using Content-Type: application/x-www-form-urlencoded

My problem is that I have a requirement to allow the creation of tokens from a client that cannot send data as Content-Type: application/x-www-form-urlencoded , it can send arguments only as Json, which according to OAuth 2 is not suitable , and in addition, Microsoft Owin does not allow this.

How can I manually create tokens for this purpose? I suppose I should create a webapi method for this, but how can I use a regular Microsoft Owin provider?

thanks a lot

+6
source share
1 answer

You can create a WebApi endpoint to act as a proxy, which means you get the arguments as JSON, and inside you can call the conversion parameters /Token to Content-Type: application/x-www-form-urlencoded .

Take a look at http://restsharp.org/ , this will facilitate your internal call to the token provider.

0
source

Source: https://habr.com/ru/post/973501/


All Articles