Get user info like name, email Id etc from authentication token in .NET Backend Azure Mobile Service

后端 未结 2 460
执笔经年
执笔经年 2021-01-06 11:56

I am using Azure Mobile Service to add authentication to my Windows Store app. Following this article from Mobile Services documentation I am able to get the UserId as well

2条回答
  •  孤城傲影
    2021-01-06 12:48

    Facebook, Google doesn't return you user profile name, e-mail when authorizing. They are giving you access token that can be used for future requests.

    You need to request for example to Facebook Graph API for name, email with your MobileServiceAuthenticationToken.

    You can use this library for accessing to Facebook API: https://facebookgraphapi.codeplex.com/

    // MobileServiceAuthenticationToken <- your token
    var facebook = new FacebookGraphAPI(MobileServiceAuthenticationToken);
    
    // Get user profile data 
    var user = facebook.GetObject("me", null);
    Console.WriteLine(user["name"]);
    

提交回复
热议问题