generated from ajturner/ajturner-prototype-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing redirect.hml for signin
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
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
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/arcgis-rest-request@3.4.3/dist/umd/request.umd.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@esri/arcgis-rest-auth@3.4.3/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> |