Providing a custom endpoint for OAuthBearerAuthenticationOptions

Jul 2, 2014 at 8:39 PM
Hi Folks,

I am trying to get an access token from an OAuth2 server and hoping to use UseOAuthBearerAuthentication extension method on IAppBuilder. What is the best way to provide a custom endpoint for retrieving the token?

Jul 2, 2014 at 9:00 PM
I think you're looking for OAuthBearerAuthenticationOptions.AccessTokenProvider, which may be a AuthenticationTokenProvider (See AuthenticationTokenProvider.OnReceiveAsync).
Jul 2, 2014 at 9:47 PM
Hi Tratcher,

Can you elaborate a bit more? ReceiveAsync takes AuthenticationTokenReceiveContext, which takes IOwinContext and has Token and AuthenticationTicket with AuthenticationProperties. AuthenticationProperties only allow RedirectUri to be set. I couldn't find any relevant properties or methods in IOwinContext either.

My intent is to have my client get an access token from an OAuth server, but haven't yet found anywhere I can provide either the URL or parameters to construct the URL.

Jul 2, 2014 at 10:24 PM
You implement OnReceiveAsync to make the HTTP request yourself for the access token, and then return the result. There's nowhere you can supply a URL and ask someone else to make the request for you.