1 Answer
- Newest
- Most votes
- Most comments
0
Well, it turns out I was close and in my Cognito identity pool I could see the identity created when signing in with Auth0 and then passing the ID token with Amplify's Credentials.set method:
import { useAuth0 } from '@auth0/auth0-react';
import { Auth } from 'aws-amplify';
import { Credentials } from '@aws-amplify/core';
....
const { isAuthenticated, loginWithRedirect, getIdTokenClaims } = useAuth0();
const config = getConfig();
useEffect(() => {
const fetchAccessToken = async () => {
const idtoken = await getIdTokenClaims();
await Credentials.set(
{
provider: config.domain,
token: idtoken.__raw,
user: { name: idtoken.email },
expires_at: idtoken.exp,
},
'federation'
);
const currentUser = await Auth.currentAuthenticatedUser();
console.log('currentUser: ', currentUser);
};
if (isAuthenticated) {
fetchAccessToken();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isAuthenticated]);
For some reason when setting up the Auth0 provider for my Cognito identity pool, I had chosen to use default mappings in the 'Attributes for access control' section. After changing this setting to Inactive
, the InvalidIdentityPoolConfigurationException
goes away!
answered 7 months ago
Relevant content
- Accepted Answerasked a year ago
- asked 3 years ago
- asked 2 years ago
- asked a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 2 years ago
Still be careful in using id token as authentication mechanism