How to get user name, email, etc. from MobileServiceUser?

前端 未结 2 1977
余生分开走
余生分开走 2021-01-24 02:20

After a lot of digging around I\'ve got my WPF application signing users in via Azure Mobile Service. My Mobile Service is connected to an Azure Active Directory that I have set

2条回答
  •  天涯浪人
    2021-01-24 02:34

    That is the userID of Azure Active Directory. You need to create a service to expose your AAD info through a service and retrieve the additional information using the access token you get from your user.

    First:

        ServiceUser user = this.User as ServiceUser;
        var identities = await user.GetIdentitiesAsync();
        var aad = identities.OfType().FirstOrDefault();
        var aadAccessToken = aad.AccessToken;
        var aadObjectId = aad.ObjectId;
    

    This will give you the access token and objectID , then you need to query the information through AAD graphy API. https://msdn.microsoft.com/library/azure/dn151678.aspx Look at the sample request part. You should provide the query with the access token you got and objectId.

提交回复
热议问题