Git Product home page Git Product logo

Comments (5)

albertorealfdez avatar albertorealfdez commented on June 14, 2024 9

I got it. In case it is useful, I just created a FacebookLoginOptions variable with scope attribute with email value, when calling the login function. Then in the API call for getting user data I added the email in the fields list In the reference documentation I left before it is explained, but not for Typescript.

This is the example code:

       let loginOption: FacebookLoginOptions = {
            scope: 'email'
        };

        this.facebookService.login(loginOptions).then(
            (response: FacebookLoginResponse) => {
                // ...
                this.getFacebookData();
            },
            (error: any) => console.error(error)
        );

       // Facebook API call for getting user data
       public getFacebookData() {
            this.facebookService.api('/me?fields=id,name,first_name,gender,email').then(
                (response: any) => {
                    console.log('Email: ', response.email);
                },
                (error: any) => console.error(error)
            );
        }

from ngx-facebook.

danielptm avatar danielptm commented on June 14, 2024

I cannot get the email address. And I am using code very similar to the above. I can get other values, but for some reason email is not apart of the returned json object

  options: LoginOptions = {
    scope: 'email,public_profile'
  };

...

facebooklogin(){

  this.fb.login(this.options)
    .then((response: LoginResponse) => {
      this.showData(response)
    })
    .catch(e => console.error('Error logging in'));

}

  showData(data){
    console.log(data);
    this.fb.api('/me?fields=email,name')
      .then((res:any)=>console.log(res))
      .catch(e=> console.log(e));


  }

returns
{name: "", id: ""}

but not email

from ngx-facebook.

danielptm avatar danielptm commented on June 14, 2024

super wierd...For some reason it has something to do with my developer account I think. I have a primary email address registered with the Facebook profile that I am using, but for some reason the email is not retrieved. I decided to create another Facebook account, I then added this account to the developer account, and i can get the email address from that account....Anyway if somebody has this problem, and you're doing the above steps, try getting the email from a different Facebook account, which might involve creating/adding a new developer to your developer account.

from ngx-facebook.

ankushbadlas avatar ankushbadlas commented on June 14, 2024

Hello ,
I am not able to get email address when I use ths ngx-facebook in my component. Please see my code.

facebookLogin(){
const options: LoginOptions = {
return_scopes: true,
enable_profile_selector: true
};

 this.fb.login(options)
 .then((response: LoginResponse) => {
   this.fbData = response.authResponse.accessToken;
  console.log(this.fbData);
  this.me(this.fbData);
 })
 .catch(e => console.error('Error logging in'));

}

me(authResponse){
let self = this;
this.fb.api('/me?fields=id,name,email,first_name,last_name,gender', 'get', {access_token:authResponse})
.then(res => {
console.log("user Results", res);
})
.catch(e => console.log(e));
}

I got all other parameter like name, id first_name but I am not getting email address. Can anybody help me about this headache issue??

from ngx-facebook.

kleeb avatar kleeb commented on June 14, 2024

I am having the same problem.
Facebook Graph Explorer throws some debug message

The field 'email' is only accessible on the User object after the user grants the 'email' permission.

I have scope email and other addons added, but the user is asked only about his name and profile picture. It happens on every version. Refreshing token in explorer solves it, but no idea whats wrong inside the SDK.

It only happens when app is added to homescreen. PWA

from ngx-facebook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.