首先是一些检查点:
不过...从FB.login和FB.api(/ me ...)获取数据时,我都会在响应中收到电子邮件。
getUserData返回“ id”和“ name”。
代码:
<div
class="fb-login-button"
data-size="large"
data-button-type="login_with"
data-layout="default"
data-auto-logout-link="true"
data-use-continue-as="true"
data-width=""
data-scope="public_profile, email">
</div>
<FoodyButton :onClick="e=>authForEmail()">ask for email</FoodyButton>
<FoodyButton :onClick="e=>getUserData()">get profile</FoodyButton>
getUserData() {
let url = '/me?fields:id,name,email';
FB.api(url, e => {
console.log('userdata' ,e);
}, {scope:'email'});
},
authForEmail() {
FB.login(
function(response) {
console.log('email:',response);
},
{
scope: 'email',
auth_type: 'rerequest'
}
);
},
也尝试过此操作(没有其他结果...)
logInWithFacebook() {
let url = '/me?fields:id,name,email';
FB.login((response) => {
console.log("Response is : ", response)
FB.api(url, (fbLogin) => {
console.log(`Good to see you, ${fbLogin.email}.`);
this.$store
.dispatch("registerOrCreateFbLogin", fbLogin)
.then((response) => {
this.$router.go(-1);
});
// }
}, {scope:'email'})
}, {scope: 'email', return_scopes:true}, {auth_type: ' '});
},