Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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");
}
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");
}
});