Reputation: 133
I use Angular 2 Cordova Oauth plugin [https://github.com/nraboy/ng2-cordova-oauth] to implement FB login in my Cordova app.
Then I succeeded fetching user access token. Here is my code.
this.oauth.logInVia(this.facebookProvider).then(success => {
console.log("RESULT: " + JSON.stringify(success));
// HERE I WANT TO SEND REQUEST TO GET USER INFORMATION
}, error => {
console.log("ERROR: ", error);
});
But I don't know the way to retrieve user details after getting Facebook access token because I don't use Facebook SDK in this app. If anyone know a solution, please answer me it.
Upvotes: 4
Views: 7192
Reputation: 29625
You need to make a GET request to Facebook Graph API with the access token received.
this.http.get(`https://graph.facebook.com/me?fields= "name,gender,location,picture/*any other fields*/&access_token=${access_token}`, new RequestOptions('Headers':new Headers({'Content-type:application/json'}))).then(result=>{});
Upvotes: 8