Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get basic user information in an Azure Mobile Web App?

I have a Xamarin.Forms app, and I'd like to implement its authentication features based on FaceBook and Azure. The authentication itself work, but I have not found the way to get basic user info from it (name, email...)

var user = await DependencyService.Get<IMobileClient>()
            .LoginAsync(MobileServiceAuthenticationProvider.Facebook);

On server side

 var mobileAppUser = (MobileAppUser)User;
 var facebookCredentials = 
     user.GetIdentityAsync<FacebookCredentials>().Result;

mobileAppUser exists, but facebookCredentials is always null.

My backend on Azure is a new mobile web app written in .net. All of its features working great, except this authentication question. I could not find the proper way to solve this problem on server side or on client side. Pls. note, my question is about the new way of Azure mobile apps, not the old classic one.

Would you be so kind to help me? Any sample code or documentation are warmly welcomed.

Thanks in advance!

like image 979
Tom Avatar asked Oct 26 '15 12:10

Tom


People also ask

What method does Microsoft Azure App Service use to obtain credentials for users?

It uses the standard OAuth 2.0 client credentials grant. In the Azure portal, select Active Directory > App registrations > New registration.

Does Azure support basic authentication?

But again, Azure AD does not support Basic Auth. And in fact, Microsoft is deprecating basic auth for Exchange Online as announced here.

When users try to access an app How does Microsoft Azure App Service get their credentials?

When a user is granted app access via Role-Based Access Control (RBAC) or coadmin permissions, that user can use their own user-level credentials until the access is revoked. Do not share these credentials with other Azure users. App-level credentials: one set of credentials for each app.


1 Answers

Too long for a comment

If you check out the implementation of GetIdentityAsync, you'll see the following:

  • It checks if the user is authenticated (you said that the user is authenticated so there's no problem here)
  • reads the "EMA_RuntimeUrl" from the config (it's not null, because then you'd get an exception)
  • it check if the token from the provider is valid or not. If not, this returns null.

I believe this is the issue you are running into. A quick search on this issue brings you to this SO question.

So have you created an EMA_RuntimeUrl manually in mobile app in azure portal in Application Properties, and assigned to Gateway address?

like image 154
Tamas Avatar answered Sep 21 '22 13:09

Tamas