|
| 1 | +<html> |
| 2 | +<head> |
| 3 | + <title>cwc_auth_1.html</title> |
| 4 | + <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1"> |
| 5 | +</head> |
| 6 | +<body> |
| 7 | + |
| 8 | +<button type="button" onclick="clearSession()">clearSession</button> |
| 9 | + |
| 10 | +<script type='text/javascript'> |
| 11 | + async function fetchAndSetIdentityToken() { |
| 12 | + const identityToken = await fetchIdentityToken(); |
| 13 | + embeddedservice_bootstrap.userVerificationAPI.setIdentityToken({ |
| 14 | + identityTokenType: "SalesforceSessionToken", |
| 15 | + identityToken: identityToken, |
| 16 | + myDomainUrl: "https://orgfarm-d585323017.test1.my.pc-rnd.salesforce.com" |
| 17 | + }); |
| 18 | + } |
| 19 | + |
| 20 | + function fetchIdentityToken() { |
| 21 | + // Execute a fetch request here an return response.json() instead of hard-coding the id_token |
| 22 | + return "00DSB00000aGFJL!AQEAQGY6LxMtdjSTX8SXOgvi7zlJ9Sv_OAD3TA4CVbQmf1TpBQu.xWxfDlZn7v3B6zfvKP7gp6nWCbm6kfTtmjCPl4DtFAO3" |
| 23 | + } |
| 24 | + |
| 25 | + function clearSession() { |
| 26 | + embeddedservice_bootstrap.userVerificationAPI.clearSession(true); |
| 27 | + } |
| 28 | + |
| 29 | + window.addEventListener("onEmbeddedMessagingReady", () => { |
| 30 | + console.log("Received the onEmbeddedMessagingReady event…"); |
| 31 | + fetchAndSetIdentityToken(); |
| 32 | + }); |
| 33 | + |
| 34 | + |
| 35 | + window.addEventListener("onEmbeddedMessagingIdentityTokenExpired", () => { |
| 36 | + console.log("Received the onEmbeddedMessagingTokenExpired event…"); |
| 37 | + fetchAndSetIdentityToken(); |
| 38 | + }); |
| 39 | +</script> |
| 40 | + |
| 41 | + |
| 42 | +<script type='text/javascript'> |
| 43 | + function initEmbeddedMessaging() { |
| 44 | + try { |
| 45 | + embeddedservice_bootstrap.settings.language = 'en_US'; // For example, enter 'en' or 'en-US' |
| 46 | + embeddedservice_bootstrap.settings.devMode = true; |
| 47 | + |
| 48 | + embeddedservice_bootstrap.init( |
| 49 | + '00DSB00000aGFJL', |
| 50 | + 'CWC_Auth_2', |
| 51 | + 'https://orgfarm-d585323017.test1.my.pc-rnd.site.com/ESWCWCAuth21771439145274', |
| 52 | + { |
| 53 | + scrt2URL: 'https://orgfarm-d585323017.test1.my.pc-rnd.salesforce-scrt.com' |
| 54 | + } |
| 55 | + ); |
| 56 | + } catch (err) { |
| 57 | + console.error('Error loading Embedded Messaging: ', err); |
| 58 | + } |
| 59 | + }; |
| 60 | +</script> |
| 61 | +<script type='text/javascript' src='https://orgfarm-d585323017.test1.my.pc-rnd.site.com/ESWCWCAuth21771439145274/assets/js/init.js' onload='initEmbeddedMessaging()'></script> |
| 62 | + |
| 63 | + |
| 64 | +</body> |
| 65 | +</html> |
0 commit comments