Reputation: 838
I am following the documentation here.
My code is like this:
async loginWithFacebook() {
var result = await this.afAuth.signInWithPopup(new auth.FacebookAuthProvider())
var user = result.user
let token = (<any>result).credential.accessToken;
this.getFacebookData(user.uid, token).subscribe(result => {
console.log(result)
})
}
getFacebookData(userId, accessToken) {
return this.http.get(`https://graph.facebook.com/${userId}
?fields=birthday,email,hometown
&access_token=${accessToken}`, { headers: new HttpHeaders({
'Authorization': '{data}',
'Content-Type' : 'application/json'
})})
}
I get this error:
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: xxxxxxxxxxxx",
"type": "OAuthException",
"code": 803,
"fbtrace_id": "xxxxxxxxx"
}
}
My Facebook login works well but I want to get the extra data. I always get the 404 or not found error. What am I doing wrong? Am I using the right user id and token generated? Your help will be much appreciated. Cheers!
Edit 1: Showing error I get.
Upvotes: 1
Views: 421
Reputation: 96373
First problem, the 404 response, is likely due to the line breaks in the API URL, so remove those.
“Some of the aliases you requested do not exist” is due to the fact that user.uid
is a the firebase-internal user id, not the Facebook user id. You can use the alias /me
instead of an actual user ID, that will automatically resolve to the user (or page) the token belongs to.
If you are not getting the requested data fields, then you most likely did not add the user for the necessary permissions so far.
Upvotes: 2