Hi All,
I am facing an Issue while accessing the token. Where am I going wrong?Here is my code....
$(document).ready(function () {
var bearer = "";
$.ajax({
type: "POST",
url: "url goes here/oauth/token?grant_type=client_credentials",
contentType: "application/x-www-form-urlencoded", dataType: "json",
beforeSend: function (request) {
request.setRequestHeader("client_id", "cline Id");
request.setRequestHeader("client_secret", "client Secrit");
request.setRequestHeader("redirect_uri", "/Callback url/login/callback"); },
, success: function (data) {
bearer = JSON.parse(JSON.stringify(data));
bearer = bearer.access_token; Authorization(); },
failure: function (response) { MessageToast.show(response.responseText); },
error: function (response) { MessageToast.show(response.responseText); } });
function Authorization() {
$.ajax({
type: "GET",
url: "/url goes here/oauth/authorize",
headers: { 'Authorization': 'Bearer ' + bearer },
contentType: "application/json", dataType: "json",
success: function (xhr, a) {
$.ajax({
url: sUrlL + alertReason + "?grant_type=client_credentials",
type: "GET", cache: false, async: true,
headers: { 'Authorization': 'Bearer ' + bearer },
dataType: 'json', contentType: "application/json",
success: function (data) {
var model = new JSONModel(data);
model.setData({ data: data }); that.getView().setModel(model, "notifData"); that.getView().getModel("notifData").getData(); },
error: function (e) { MessageToast.show(e.statusText); }
}); },
failure: function (response)
{ MessageToast.show(response.responseText); },
error: function (response) { MessageToast.show(response.responseText); } });
Thank you,
poornima