Created
March 12, 2021 09:59
-
-
Save somaria/e965264060502a3c1554953487c7dcff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> | |
<script src="https://stg-id.singpass.gov.sg/static/ndi_embedded_auth.js"></script> | |
<script> | |
function getData(ajaxurl) { | |
return $.ajax({ | |
url: ajaxurl, | |
type: "GET" | |
}); | |
} | |
async function init() { | |
const authParamsSupplier = async () => { | |
try { | |
const res = await getData( | |
"https://singpasslogin.herokuapp.com/getstate" | |
); | |
return res; | |
} catch (err) { | |
console.log(err); | |
} | |
}; | |
const onError = (errorId, message) => { | |
console.log(`onError. errorId:${errorId} message:${message}`); | |
}; | |
const initAuthSessionResponse = window.NDI.initAuthSession( | |
"ndi-qr", | |
{ | |
clientId: "abcd1234", // Replace with your client ID | |
redirectUri: "https://primuslogin.firebaseapp.com/callback/", // Replace with a registered redirect URI | |
scope: "openid", | |
responseType: "code" | |
}, | |
authParamsSupplier, | |
onError | |
); | |
console.log("initAuthSession: ", initAuthSessionResponse); | |
} | |
</script> | |
<body onload="init()"> | |
<h3>Pure JS HTML login</h3> | |
<div id="ndi-qr"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment