How to use the @esri/arcgis-rest-auth.UserSession.exchangeAuthorizationCode function in @esri/arcgis-rest-auth

To help you get started, we’ve selected a few @esri/arcgis-rest-auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Esri / arcgis-rest-js / demos / webmap-checker-sapper / src / routes / auth / post-sign-in.js View on Github external
export async function get(request, response, next) {
  // exchange the auth token for a full `UserSession`
  request.session.userSession = await UserSession.exchangeAuthorizationCode(
    {
      clientId: CLIENT_ID,
      redirectUri: REDIRECT_URI
    },
    request.query.code
  );

  // once we have the session set redirect the user to the /webmaps
  // route so they can use the app.
  response.redirect("/webmaps");
}
github Esri / arcgis-rest-js / demos / express / server.js View on Github external
app.get("/authenticate", function(req, res) {
  if (credentials) {
    UserSession.exchangeAuthorizationCode(
      credentials,
      req.query.code
    ).then(session => {
      res.send(session.token);
    });
  } else {
    res.send("please visit http://localhost:3000/authorize");
  }

});