2

I'm using Azure mobile services with .net backend. My API controller works OK on my pc but as soon as I deploy it to Azure, Upon pinging from Postman gives "Authorization has been denied for this request." message with HttpStatusCode 401

Note that... I'm using table storage for storage instead of SQL Server and in the process removed all of Entity Framework related code. Also, None of the endpoints do not require any authentication.

Thanks.

Sameer Vartak
  • 948
  • 11
  • 14

1 Answers1

6

The default authentication for mobile services is anonymous (i.e., no authentication required) when running locally, and application (i.e., at least the application key needs to be supplied).

If you're using Postman, try adding a "x-zumo-application" header to the request, with the application key (which you can get in the Azure portal) as the value. The request should work then.

carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
  • Excellent thanks a lot. I was banging my head against this for too long! Just so I know, I will have to assign this header for every outgoing request from my WPF and Web app ? – Sameer Vartak Jun 30 '14 at 17:56
  • If you use the SDK, you can pass the app key to the constructor to the MobileServiceClient object (in each of the supported platforms), and the SDK will take care of adding the header to the outgoing requests. If you use authentication, you don't need to use that header (another header for authenticated requests will be used by the SDK). – carlosfigueira Jun 30 '14 at 20:47
  • Where to get this Application Key in the latest Azure App services? The app key used to be available as part of default configuration using Mobile Services, but they are now not available in Azure app services as I've mentioned here in this separate question. http://stackoverflow.com/questions/34631080/where-is-the-key-in-new-azure-app-service – Supreet Jan 06 '16 at 12:11
  • @carlosfigueira Can you look at this https://stackoverflow.com/questions/45061308/jwt-token-isnt-validated-even-if-its-correct-using-microsoft-azure-mobile-sdk Question is similar should we pass this header when running locally? – Hiren Desai Jul 13 '17 at 06:26