Azure-Samples/active-directory-angularjs-singlepageapp-dotnet-webapi

401 Unauthorized after publish to Azure

nigel-dewar opened this issue · 4 comments

sample works great in local host, after publish to azure I get 401 Unauthorized.

Why is that?

da3a commented

I was having the same issue. Finally resolved it by,

  • Using a JWT Inspector and identyfing that the Aud property in the token sent to the API was set to to the SPA ClientId. I then made sure the ida:Audience value in the API app was the same.
  • I found hard coding ida:Audience and ida:Tenant values into the API Startup.Auth class worked. This made me think the config wasn't being picked up as expected which I confirmed by creating these settings against the web app in azure after which I could again use ConfigurationManager to pick up these settings.
  • To the API project I'd had to install the package Microsoft.AspNet.WebApi.Cors and add the attribute
    Microsoft.AspNet.WebApi.Cors [EnableCors("", "", "*", SupportsCredentials = false)] to the ToGoListController

Thanks very much. Ill check this out.!

Hi All

Similar issue here, working fine locally, Followed the ReadMe for Publish to Azure, error is {"Message":"An error has occurred."} a 500 error. Any help appreciated.

ClientId is the same as Application ID?

I have set the Audience in the API App to the App URI and to the Application ID for the SPA client app.

Thanks

Closing this as we are archiving this sample. Please check out the new sample at ms-identity-javascript-angular-spa-aspnetcore-webapi.