0
votes

I am testing out Azure cloud for mobile app and downloaded the sample app provided during the getting started section. I also configured Azure Active Directory to be used for authentication.

When I run the app on iOS simulator, I get an error in terminal saying:

ERROR Error Domain=com.Microsoft.MicrosoftAzureMobile.ErrorDomain Code=-1302 "You must be logged in to use this application" UserInfo={com.Microsoft.MicrosoftAzureMobile.ErrorResponseKey= { URL: https://appname.azurewebsites.net/tables/TodoItem } { status code: 401, headers { "Content-Length" = 45; "Content-Type" = "text/html; charset=utf-8"; Date = "Sat, 25 Jun 2016 10:46:04 GMT"; Etag = "W/\"2d-vonn2FgYR/Z6jU4A0udEWA\""; Server = "Microsoft-IIS/8.0"; "Set-Cookie" = "ARRAffinity=155c1827c98c621a5b3208e361587e118813cc4207f5ad4c23e121c5c10fd7bf;Path=/;Domain=appname.azurewebsites.net"; "X-Powered-By" = "Express, ASP.NET"; } }, NSLocalizedDescription=You must be logged in to use this application, com.Microsoft.MicrosoftAzureMobile.ErrorRequestKey= { URL: https://appname.azurewebsites.net/tables/TodoItem }} Error: Error Domain=com.Microsoft.MicrosoftAzureMobile.ErrorDomain Code=-1173 "Push aborted due to authentication error" UserInfo={NSLocalizedDescription=Push aborted due to authentication error, NSUnderlyingError=0x7f84fb1bd910 {Error Domain=com.Microsoft.MicrosoftAzureMobile.ErrorDomain Code=-1302 "You must be logged in to use this application" UserInfo={com.Microsoft.MicrosoftAzureMobile.ErrorResponseKey= { URL: https://appname.azurewebsites.net/tables/TodoItem } { status code: 401, headers { "Content-Length" = 45; "Content-Type" = "text/html; charset=utf-8"; Date = "Sat, 25 Jun 2016 10:46:04 GMT"; Etag = "W/\"2d-vonn2FgYR/Z6jU4A0udEWA\""; Server = "Microsoft-IIS/8.0"; "X-Powered-By" = "Express, ASP.NET"; } }, NSLocalizedDescription=You must be logged in to use this application, com.Microsoft.MicrosoftAzureMobile.ErrorRequestKey= { URL: https://appame.azurewebsites.net/tables/TodoItem }}}}

Nonetheless the app is working and I can save items and load data. How can I solve the below issue?

1
How did you configure the backend? Did you set the Authentication / Authorization default action to be "Allow request"? (This is required so that the app controls auth instead of the front end processors) - Adrian Hall

1 Answers

1
votes

The app probably appears to work because it is saving items to the local database, but you are getting errors when trying to sync. I'm guessing you configured authentication on a service level when you set it up. You can change it to only be required for particular endpoints by changing the setting in Authentication/Authorization under "action to take when request is not authenticated" to "allow request (no action)". See How authorization works in App Service.

For endpoints that do require authentication, you need to add code to login on the client. See Add authentication to your iOS app.