HTML Signing using AWS Cognito Steps

Step 1:

Step 2:

Step 3:

Step 4:

Step 5:

Step 6:

Step 7:

Step 8:

Step 9:

Step 10:

Step 11:

Step 12:

Step 13:
Step 14:
Step 15:
Step 16:
Step 17:
Step 18:
Step 19:
Step 20:
Sign InSign Out
Step 21:
Secure Page Java Script
const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get('code');
if (code) {
const clientId = '33j7pmut60879qo7uu1etj76fp';
const redirectUri = 'https://dev.kishoreweb.com/index.html';
const url = 'https://kishoreweb.auth.ap-south-1.amazoncognito.com/oauth2/token';
const data = {
grant_type: 'authorization_code',
client_id: clientId,
redirect_uri: redirectUri,
code: code
};
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams(data)
})
.then(response => response.json())
.then(data => {
if (data.id_token) {
localStorage.setItem('id_token', data.id_token);
// Allow access to your content
showContent();
} else {
// Handle errors
window.location.href = 'https://kishoreweb.auth.ap-south-1.amazoncognito.com/login?client_id=YOUR_CLIENT_ID&response_type=code&redirect_uri=https://dev.kishoreweb.com/index.html';
}
});
} else if (!localStorage.getItem('id_token')) {
// Redirect to Cognito sign-in page if no token found
window.location.href = 'https://kishoreweb.auth.ap-south-1.amazoncognito.com/login?client_id=YOUR_CLIENT_ID&response_type=code&redirect_uri=https://dev.kishoreweb.com/index.html';
} else {
// User is already authenticated
showContent();
}
function showContent() {
document.getElementById('content').style.display = 'block';
}
Step 22:
Step 23:
Step 24:
Step 25:
Step 26: