且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过Facebook的AWS Cognito身份验证成功,但getCurrentUser返回null

更新时间:2022-12-06 16:47:37

外观就像您需要更改您的 AWSCognito.config.credentials b一样。

Looks like you need to change your AWSCognito.config.credentials From what you have to this:

// Add the Facebook access token to the Cognito credentials login map.
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
  IdentityPoolId: 'IDENTITY_POOL_ID',
  Logins: {
    'graph.facebook.com': response.authResponse.accessToken
  }
});

// Obtain AWS credentials
AWS.config.credentials.get(function(){
    // Access AWS resources here.
});

注意 IdentityPoolId: IDENTITY_POOL_ID,而不是 IdentityPoolId:'<%= process.env.AWS_USERPOOLGUID%>',//您的身份池ID在此处

看起来像您正在尝试访问您的 USER POOL ,而不是您的 IDENTITY POOL

Looks like you are trying to access your USER POOL and not your IDENTITY POOL.

Facebook用户位于身份池中因为他们是来自Facebook服务器的联合用户。

Facebook users live in the Identity Pool because they are a federated user from the Facebook server.