Getting error "No Cognito Identity pool provided for unauthenticated access"

0

I am getting this error in my web application after login. The user is part of Userpool for the Prod environment. The userpool is already connected to identity pool. Also, unauth roll is assigned in identity pool. Its working all find in dev environment, not able to figure out what is wrong in prod environment.

질문됨 일 년 전2629회 조회
1개 답변
0

The fact that the User Pool is "connected" to the Identity Pool only means that the Identity Pool will consider trusted any valid Identity Token issued by the User Pool and provided as part of the Auth.currentAuthenticatedUser(); to retrieve AWS credentials.

But this does not allow the client to understand to which Identity pool it has to communicate to with the Identity Token it received from the User Pool. You are missing a configuration and therefore got this error.

You can find an example for Javascript at: https://docs.amplify.aws/lib/auth/advanced/q/platform/js/#subscribing-events

import { Auth } from 'aws-amplify';

// To derive necessary data from the provider
const {
    token, // the token you get from the provider
    domainOrProviderName, // Either the domain of the provider(e.g. accounts.your-openid-provider.com) or the provider name, for now the library only supports 'google', 'facebook', 'amazon', 'developer'
    expiresIn, // the time in ms which describes how long the token could live
    user,  // the user object you defined, e.g. { username, email, phone_number }
    identity_id // Optional, the identity id specified by the provider
} = getFromProvider(); // arbitrary function

Auth.federatedSignIn(
    domain,
    {
        token,
        identity_id, // Optional
        expires_at: expiresIn * 1000 + new Date().getTime() // the expiration timestamp
    },
    user
).then(cred => {
    // If success, you will get the AWS credentials
    console.log(cred);
    return Auth.currentAuthenticatedUser();
}).then(user => {
    // If success, the user object you passed in Auth.federatedSignIn
    console.log(user);
}).catch(e => {
    console.log(e)
});

as you can see identity_id must be set for the client to know with which Identity Pool to communicate.

AWS
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠