Angular - Facebook登录打开窗口说:"Sorry, something went wrong. We're working on getting this fixed as soon



来自 angular 组件的 Facebook 登录操作打开窗口,显示:"对不起,出了点问题。我们正在努力尽快解决此问题。

回去"

昨天它工作正常。 我尝试调试它,但没有找到任何东西。控制台在"@login.component.ts:58"中显示未定义这就是我发现错误的地方。我从浏览器(Chrome)中删除了所有cookie,缓存和历史记录。我保留了应用程序,我试图在谷歌中寻找答案,但没有找到任何有帮助的东西。

export class LoginComponent implements OnInit {
  constructor(private FB: FacebookService) {
    let initParams: InitParams = {
      appId: 'my-app-id',
      xfbml: true,
      version: 'v3.2'
    };
    FB.init(initParams);
  }
ngOnInit() {
(window as any).fbAsyncInit = function() {
  this.FB.init({
    appId      : 'my-app-id',
    cookie     : true,
    xfbml      : true,
    version    : 'v3.2'
  });
  this.FB.AppEvents.logPageView();
};
(function(d, s, id) {
   let js, fjs = d.getElementsByTagName(s)[0];
   if (d.getElementById(id)) {return; }
   js = d.createElement(s); js.id = id;
   js.src = "https://connect.facebook.net/en_US/sdk.js";
   fjs.parentNode.insertBefore(js, fjs);
 }(document, 'script', 'facebook-jssdk'));
  }
  facebookLogin() {
     debugger;
     const loginOptions: LoginOptions = {
      enable_profile_selector: true,
      return_scopes: true,
      scope: 'user_birthday,default,email',
      auth_type: 'rerequest'
};
this.FB.login(loginOptions)
  .then((response: LoginResponse) => {
    let array = response.authResponse.grantedScopes.split(',');
    if(array.length === 3) {
    } else {
       alert('You need to provide all the facebook permissions to use the app.');
    }
 })
  .catch((error: any) => console.error(error));
   }

我希望"继续作为myName"窗口,但我得到"对不起,出了点问题。我们正在努力尽快解决此问题。窗

编辑 1下一节不要打开窗口"以我的名字继续"但它确实返回了一个带有令牌、用户 ID 等的对象,并且不会抛出异常:

facebookLogin() {
this.FB.login()
  .then((response: LoginResponse) => console.log(response));
}

我仍然需要窗口来请求权限。

解决方案: 问题是写下 .then 一行所以代替:

this.FB.login(loginOptions)
.then((response: LoginResponse) =>

我应该这样做:

this.FB.login(loginOptions).then((response: LoginResponse) =>

此外,登录选项中的 scope 属性必须包含:"public_profile"

const loginOptions: LoginOptions = {
  enable_profile_selector: true,
  return_scopes: true,
  scope: 'email,public_profile',
  auth_type: 'rerequest'
};

最新更新