nraboy / ng-cordova-facebook-example

Ionic Framework ngCordova Oauth Example for Facebook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to fetch profile after login

asambeka opened this issue · comments

I have plugin installed and login seems to be working. I get access_token, but graph API call fails with error {"data":{"error":{"message":"Invalid OAuth access token.","type":"OAuthException","code":190}},"status":400,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"params":{"access_token":{"access_token":"C....3"},"fields":"id,name,first_name,last_name,email,gender,location,age_range,user_birthday","format":"json"},"url":"https://graph.facebook.com/v2.2/me","headers":{"Accept":"application/json, text/plain, /"}},"statusText":"BadRequest"}

Any idea on this one?

[Update] Access Token is valid, as I could search profile using Facebook Graph Explorer and Access Token returned, but graph API call fails:
$http.get("https://graph.facebook.com/v2.2/me", {
params: {
access_token: res.rows.item(0),
fields: "id,name,first_name,last_name,email,gender,location,age_range",
format: "json"
}
}).then(function (result) {
$scope.profileData = result.data;
}, function (error) {
alert("There was a problem getting your profile. Check the logs for details.");
console.log(JSON.stringify(error));
});

res.rows.item(0) is the access_token (prints correctly in console.log)

I was able to resolve,

  1. App configuration (callback URL and OATH settings)
  2. replaced res.rows.item(0) with res.rows.item(0).access_token (I am using cordova SQLite).