Azure Mobile Services vs MVC4 SimpleMembership

When using the ASP.Net MVC4 site, it is very easy to add OAuth authentication using SimpleMembership.

OAuthWebSecurity.RegisterTwitterClient(consumerKey,consumerSecret); 

When using Azure Mobile Services on a client device, it is very easy to add OAuth authentication.

 await App.MobileService.LoginAsync(MobileServiceAuthenticationProvider.Twitter); 

The problem is that these are two different data stores. I need users to be able to register and / or log in from an application or site. What is the best / easiest way to provide integrated OAuth authentication from ASP.Net devices and site? Are samples available?

+4
source share
2 answers

I was only able to achieve this with the Twitter and Facebook logins when playing Azure Mobile Services and MVC SimpleMembership. Please browse through this topic, which admittedly has a lot of room for study, but that explains my findings pretty well.

http://social.msdn.microsoft.com/Forums/en-US/azuremobile/thread/d54d28c6-6941-4af5-b116-dc8c51820498

Sorry, I could not give you any code, because my stated goal was not to write an authentication / security code for this integration.

Nat

+3
source

I just finished publishing a sample that uses simple ASP.NET MVC4 membership for authentication on the Azure Mobile Service (via Facebook, in my example) at http://blogs.msdn.com/b/carlosfigueira/archive/2013/06/ 25 / exposing-authenticated-data-from-azure-mobile-services-via-an-asp-net-mvc-application.aspx . The message contains a lot of details, but the idea is that if you can get the provider access token (for example, from Facebook or Google), you can format it and send it to the mobile support service. In the snippet below, the facebook token was stored in session state and retrieved using a method that ensures that the user is logged in.

  if (MobileService.CurrentUser == null) { var accessToken = Session["facebooktoken"] as string; var token = new JObject(); token.Add("access_token", accessToken); return MobileService.LoginAsync(MobileServiceAuthenticationProvider.Facebook, token).ContinueWith<bool>(t => { if (t.Exception != null) { return true; } else { System.Diagnostics.Trace.WriteLine("Error logging in: " + t.Exception); return false; } }); } 
0
source

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


All Articles