Skip to content

Commit

Permalink
Added missing redirect.hml for signin
Browse files Browse the repository at this point in the history
  • Loading branch information
ajturner committed Jul 18, 2024
1 parent e351e86 commit 263e6dc
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/redirect.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>ArcGIS Rest JS OAuth redirect</title>
</head>

<body>
<script src="https://cdn.jsdelivr.net/npm/@esri/[email protected]/dist/umd/request.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@esri/[email protected]/dist/umd/auth.umd.js"></script>
<script>
/* in a production app, clientId could be hardcoded. here we're using a
regex to extract it from the state parameter in the OAuth2 server response
to make the demo more interchangeable.
this relies on the fact that the ClientId is associated with the state parameter
internally when another value isn't supplied manually.
*/
const match = window.location.href.match(/&state=([^&]+)/);
const clientId = match[1];
let session;
function processAuthentication() {
window.location.href = './';
session = arcgisRest.UserSession.completeOAuth2({
clientId: clientId,
});
localStorage.setItem('__ARCGIS_REST_USER_SESSION__', session.serialize());
}
processAuthentication();
</script>
<h2>Redirect</h2>
</body>
</html>

0 comments on commit 263e6dc

Please sign in to comment.