auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
let type = "text/html";
let myBody = "";
let code;
let obj;
if( Object.keys(steps.trigger.event.query).length !== 0 ){
code = steps.trigger.event.query.code;
$checkpoint = code;
console.log("Get new code", $checkpoint);
myBody= '<!DOCTYPE html><html>'
+ '<head><meta charset="utf-8"/>'
+ '<meta name="viewport" content="initial-scale=1.0"/><title>OAuth2.0 endpoint</title>'
+ '<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">'
+ '</head>'
+ '<body><div class="container-fluid" style="padding: 40px; margin: 70px, auto">'
+ '<div class="alert alert-success" role="alert">'
+ '<img src="https://icons.iconarchive.com/icons/custom-icon-design/flatastic-10/128/File-complete-icon.png"><br><br>'
+ '<h4 class="alert-heading">Well done!</h4>'
+ '<p>Authorization code was succesfully generated</p><hr> <br><br>'
+ '<p class="mb-0">Please, close this window and click on button <br><b>Exchange authorization code for tokens</b></p><br><br>'
+ '</div><button class="btn btn-primary float-right" onclick="javascript:window.close();opener.window.focus();">Close this Window</button>'
+ '</div></body>';
type = "text/html";
}
else {
console.log("Retun last auth code")
myBody = {"code" : $checkpoint};
type = "application/json";
}
$respond({
status: 200,
headers: { "Content-Type": type },
body: myBody,
});