问题描述: 在使用Auth0的getTokenSilently方法时,返回undefined。
解决方法:
以下是一个使用Auth0的getTokenSilently方法的示例代码:
import { Auth0Client } from '@auth0/auth0-spa-js';
const auth0 = new Auth0Client({
domain: 'your-auth0-domain',
client_id: 'your-client-id',
audience: 'your-audience',
redirect_uri: 'your-redirect-uri',
});
async function getToken() {
try {
const token = await auth0.getTokenSilently();
console.log(token);
} catch (error) {
console.error(error);
}
}
getToken();
请确保替换示例代码中的以下值:
如果问题仍然存在,请确保检查Auth0 SDK的版本和文档,以获取更多信息和解决方案。