Question

I am trying to integrate Facebook login in an Xamarin Android application using Azure Mobile Services.

  MobileServiceUser user = await client.LoginAsync(this.Activity, MobileServiceAuthenticationProvider.Facebook); 
  var httpClient = new System.Net.Http.HttpClient(); 
  var url = "https://graph.facebook.com/me?access_token=" + user.MobileServiceAuthenticationToken;
  var fbUser = await httpClient.GetAsync(url); 
  var response = await fbUser.Content.ReadAsStringAsync();

And i get :

{
   "error": {
      "message": "Bad signature",
      "type": "OAuthException",
      "code": 1
   }
}

Do you have any idea is the returned access token invalid ? Or MobileServiceAuthenticationToken is not the facebook access token i should use?

Was it helpful?

Solution

The MobileServiceAuthenticationToken is for authenticating to your Mobile Service, not for connecting to Facebook's Graph API. If you want to talk to the Facebook Graph API from the client application, you'll need to talk to your Mobile Service to get the user's Facebook token and secret. Alternatively, you can do it in the server side logic of your Mobile Service. Check out this article for more information on doing that: http://blogs.msdn.com/b/carlosfigueira/archive/2012/10/25/getting-user-information-on-azure-mobile-services.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top