I followed this tutorial to authenticate with Azure AD for my Azure Mobile Service but I can't get the URL redirect working. Maybe I have misunderstood but this is what I have tried ...
In the iOS project
I added this URL Scheme to info.plist: com.spike.Xamarin.OAuth:/oauth2redirect
I override the AppDelegate.OpenUrl
method(s) (both overloads) and implement the code from the tutorial
In the PCL project
I pass the authentication URL as https://(my service).azurewebsites.net/.auth/login/aad
and as the redirect URL I pass the same URL (above) to the Xamarin.Auth.OAuth2Authenticator
ctor.
I add an event handler to the Xamarin.Auth.OAuth2Authenticator.Completed
event, to fetch the access token and so on.
In my protected Azure Mobile service (AAD / Express)
I registered the above URL reversed: OAuth.Xamarin.spike.com:/oauth2redirect
as an 'ALLOWED EXTERNAL REDIRECT URLS'.
Result
What happens is I get to the login page and I am able to fill in my credentials as expected. But the final redirect never hits the AppDelegate.OpenUrl method. Instead iOS Safari seems to end up at https://(my service).azurewebsites.net/.auth/login/aad/callback
.
What am I getting wrong here?