简体   繁体   中英

Creating Redirect URI for OAuth2 in ASP.NET

I have Asp.Net MVC application and Xamarin.Forms mobile application with Azure Mobile App as back end. All will be hosted in Azure cloud. I need to integrate Google, Microsoft and Azure AD authentication into it.

I came across many tutorials/blogs on how to do this, but none on how to create my own redirect URI.

I would like to create one universal redirect URI for each of the authentication provide and host it in cloud. Basically it should process the token, and I would like to retrieve basic user properties like user ID and name to be returned back to the calling app - in my case either the MVC or Xamarin mobile app.

Appreciate any sample project on this.

I think following two urls should be able to give you good idea about how to use oauth in azure mobile:

http://www.strathweb.com/2014/02/running-owin-pipeline-new-net-azure-mobile-services/

http://blog.nankov.com/azure-mobile-services-configuring-the-owin-pipeline/

As per oauth itself. The you will need to understand (if you havent already) different oauth flow types and decide which one best suits your scenario.

https://tools.ietf.org/html/rfc6749

For eg if you are using pure javascript client then implicit grant will be the best option in my view.

If you look at the implicit grant flow (for eg) it uses redirect uri. So When client makes a request , it uses a predefined url (given by the auth server to the client before hand). The server look at the url (and the client_id) and if it matches then it sends the response back (with a token) to that url only.

The url is location at the client's app would be something like https://client.com/someuniquelocation/ (for eg)

Hope this helps.

Edit:

Have a look at the following:

Redirect to ReturnUrl after successful cookie authentication in Owin, Katana & Nancy

http://xabikos.com/web%20application/interception/middleware/2015/01/26/asp.net---create-an-owin-middleware-to-trigger-a-permanent-redirect.html

https://msdn.microsoft.com/en-us/library/microsoft.owin.owinresponse.redirect(v=vs.113).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM