0
votes

Call the login method, enter valid credentials then get:

You do not have permission to view this directory or page

The url in the pop-up windows is: "https://zzz.azurewebsites.net/.auth/login/aad/callback"

I'm expecting the login method to simply complete and return a user (or auth token etc) as it does when using the MobileServiceClient in my mobile (Xamarin) apps.

      this.client = new WindowsAzure.MobileServiceClient('https://zzz.azurewebsites.net');
  this.client.login("aad").done(function (results) {
    console.log(results); 
  alert("You are now logged in as: " + results.userId);
  }, function (err) {
      alert("Error: " + err);
  });

I am debugging this web app on my local machine.

2
How is CORS set up on your app service? - Adrian Hall
I don't have any CORS entries in my App Service. - Triple888Three

2 Answers

1
votes

Azure Portal > App Service > your Mobile App > Tools > Resource explorer > Go.

Expand the config, authsettings nodes for your site in the left hand navigation. Click on Edit

Look for the "allowedExternalRedirectUrls" element. It will be set to null. Change it to the following:

 "allowedExternalRedirectUrls": [
     "http://localhost:3000",
     "https://localhost:3000"
 ],

Replace the URLs with the URLs of your service.

https://github.com/Azure/azure-content/blob/master/articles/app-service-mobile/app-service-mobile-cordova-how-to-use-client-library.md#how-to-configure-your-mobile-app-service-for-external-redirect-urls

0
votes

It's best to test authentication for the app when hosted on Azure as Azure contains the full authentication implementation. A stub exists for local development, but it has a number of caveats, such as not working for some platforms and requiring HTTPS for some platforms.