I am attempting to utilize AWS Amplify but have had troubles accessing it as even when it gets imported using a cdn import script, the variable is always undefined.
I have tried to access it through the global variable of Amplify or Auth or Core but have had no success. The idea is to add simple authentication in a navigation bar that is present across our Hubspot site but also syncs with other custom applications we have (that use AWS Amplify as auth).
Any ideas? Thanks!
<head>
<script src="https://cdn.amplify.aws/packages/auth/5.0.5/aws-amplify-auth.js" integrity="sha384-JY7EPYO7yzN38lNyktbhs1Q/pQOYiLeZMSp+f9Eh/bC/fjNAeo5TFj6aa3TkyYxk" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdn.amplify.aws/packages/core/5.0.5/aws-amplify-core.js" integrity="sha384-0RR1Aiawg9L3lRiLbicLRIceRDH5qoKXo1m/jX80E1I3z4G5up8bER52Zqj5Xldn" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="module">
async function configureAuth() {
if (typeof window['aws-amplify'] !== 'undefined') {
const Amplify = await window['aws-amplify'];
const Auth = Amplify.Auth;
Auth.configure({
mandatorySignIn: true,
region: '***',
userPoolId: '***',
userPoolWebClientId: '***'
});
} else {
console.log("Auth is not loaded");
}
}
document.addEventListener('DOMContentLoaded', function() {
configureAuth();
});
</script>