Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 as MobileServiceAuthenticationToken (both for Google as well as Microsoft Account)

My question is how do I get user info like name, email Id etc. using MobileServiceAuthenticationToken in a .NET backend mobile service. I have gone through various articles explaining how this is done in Javascript Backend mobile service but couldn't find anything properly implemented in C# + .NET backend mobile service.

Any pointers appreciated.

Thanks

like image 822
Shivkanwer Singh Avatar asked Dec 25 '22 14:12

Shivkanwer Singh


1 Answers

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"]);
like image 162
bot_insane Avatar answered Dec 28 '22 07:12

bot_insane