1 個回答
- 最新
- 最多得票
- 最多評論
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!
已回答 8 個月前
相關內容
- 已提問 10 個月前
- AWS 官方已更新 2 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 2 年前
Still be careful in using id token as authentication mechanism