Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 爱奥尼亚4如何使用aws cognito会话登录facebook?_Angular_Amazon Web Services_Ionic Framework_Amazon Cognito - Fatal编程技术网

Angular 爱奥尼亚4如何使用aws cognito会话登录facebook?

Angular 爱奥尼亚4如何使用aws cognito会话登录facebook?,angular,amazon-web-services,ionic-framework,amazon-cognito,Angular,Amazon Web Services,Ionic Framework,Amazon Cognito,我写了这段代码,让我登录facebook,但有一个问题,我需要cognito的会话令牌才能工作,我不知道如何获取它 facebookSignin(){ // Login with permissions this.fb.login(['public_profile', 'email']) .then((loginres: FacebookLoginResponse) => { // The connection was successful if (

我写了这段代码,让我登录facebook,但有一个问题,我需要cognito的会话令牌才能工作,我不知道如何获取它

facebookSignin(){
    // Login with permissions
   this.fb.login(['public_profile', 'email'])
   .then((loginres: FacebookLoginResponse) => {
     // The connection was successful
     if (loginres.status === 'connected') {
       // Get user infos from the API
       this.fb.api('/me?fields=name,gender,birthday,email', [])
         .then((profileres: any) => {
         let user =  {
            username  : profileres.name,
            password  : '',
            preferred_username : profileres.name,
              email            : profileres.email,
              phone_number      : profileres.phone_number,
              given_name       : profileres.name,
              family_name        : profileres.family_name,
              locale         : '',
              role        : 'sellers',
          }

          console.log('Uploading info....');

          this.amplify.setAuthState({state: 'fbLogin', user});
         });
     } else { // An error occurred while loging-in
       console.log('An error occurred...');
     }
   })
  }
这段代码将我与所有数据一起登录到facebook,但随后我从这段代码中得到错误,该代码检查会话:

getSession(authState){
const idTokenPayload = authState.getSignInUserSession().getIdToken().decodePayload();

....
}
getSignInUserSession()不是一个函数


Cognito有两个不同的资源,一个用户池和一个身份池。这两者的设计似乎有些不直观,特别是在我们正在考虑的联合身份验证场景中。为了使水更加浑浊,可以使用诸如facebook之类的联邦身份对用户池进行身份验证,但只能通过网页和本机应用程序而不是ionic应用程序进行验证

认知用户池支持联邦认证;但仅限于AWS托管页面。(在编写本文时)不可能从提供者令牌直接向Cognito用户池进行身份验证。这是一个非常明显的限制,这意味着除非我们想启动AWS托管的Cognito页面,否则我们无法在我介绍的场景中使用用户池

相反,我们需要使用Cognito身份池从Facebook令牌进行身份验证。为此,我们使用客户端sdk登录Facebook,然后使用Auth.federatedSignIn()对Cognoto用户池进行身份验证

这样做的缺点是我们无法从Cognito用户池的功能中获益

针对AppSync API的直接身份验证 在用户池中存储用户信息 请找到下面的文章