function requestToken() {
var issuerID = "STRING";
const baseUrl = "https://sec-id-api.sandbox.securitize.io/v1/"
+ issuerID + "/oauth2/authorize";
var scope = "info details verification";
var redirecturl = "STRING";
var OAuthSecret = "STRING";
// Get the CODE in the URL
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const code = urlParams.get("code");
var data = JSON.stringify({
"code": code
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
if (this.status === 200) {
// User is logged-in and has authorized the app
// Know we can get the TOKEN and start interacting
var response = JSON.parse(this.responseText);
console.log("Authorized with access Token: ", response.accessToken);
}
console.log(this.responseText);
}
});
xhr.open("POST", baseUrl);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", OAuthSecret);
xhr.send(data);
}