I currently have a backend solution for my application using Azure Mobile Apps. I have included login, twitter, google and Microsoft. Also, I am trying to add a user login. I have an Auth0 account and application installed, and I can get the token and profile back from auth0 when I make a request in the application using the auth0 lock widget.
I followed this guide: https://shellmonger.com/2016/04/08/30-days-of-zumo-v2-azure-mobile-apps-day-5-custom-authentication/ and went to the "Custom Validation" stage JWT on the server ", but this is where I got stuck ... my backend is in C # not node.js, since I can do the equivalent of this tutorial and check the JWT token and subsequently access the table controllers from my external application using azureClient.login / azureClient.table?
EDIT: Well, as you will see in the comment the thread below with @AdrianHall I managed to create a token from my cordova application, but my sticking point now is receiving a service to accept it without exchanging tokens. This is possible according to the published manual.
This is my client side code that is currently making an auth call to auth0 and creates some client side to get the user id and generates a currentUser object containing the new token.
auth0.lock.show(auth0.options, function(err, profile, token) { if (err) { console.error('Error authenticating with Auth0: ', err); alert(err); } else { debugger; var userID; if (profile.user_id.indexOf("auth0") > -1) { userID = profile.user_id.replace("auth0|", ""); } else if (profile.user_id.indexOf("facebook") > -1) { userID = profile.user_id.replace("facebook|", ""); } else if (profile.user_id.indexOf("twitter") > -1) { userID = profile.user_id.replace("twitter|", ""); } else if (profile.user_id.indexOf("microsoft") > -1) { userID = profile.user_id.replace("microsoft|", ""); } else if (profile.user_id.indexOf("google-oauth2") > -1) { userID = profile.user_id.replace("google-oauth2|", ""); } window.azureClient.currentUser = { userId: userID, profile: profile, mobileServiceAuthenticationToken: token };
Internal Code MobileAppSettingsDictionary
settings = config.GetMobileAppSettingsProvider().GetMobileAppSettings(); if (string.IsNullOrEmpty(settings.HostName)) { //This middleware is intended to be used locally for debugging.By default, HostName will //only have a value when running in an App Service application. app.UseAppServiceAuthentication(new AppServiceAuthenticationOptions { SigningKey = ConfigurationManager.AppSettings[""], ValidAudiences = new[] { ConfigurationManager.AppSettings[""] }, ValidIssuers = new[] { ConfigurationManager.AppSettings["https://domain.eu.auth0.com/"] }, TokenHandler = config.GetAppServiceTokenHandler() }); }
c # cordova auth0 azure-mobile-services
anthonyhumphreys
source share