Hi,
-
I ran into cross domain issues when using jquery ajax method to generate an access token.
-
I got below error using jsonp.Moreover i don’t think POST method and custom headers are possible with jsonp.
Failed to load resource: the server responded with a status of 404 (Not Found)
Following is my code
var appId = 'urn:aid:52f30e00-b000-467f-9490-16551b462f24';
var oHeader = { alg: 'RS256', typ: 'JWT' };
var oPayload = {};
var tNow = KJUR.jws.IntDate.get('now');
var tEnd = KJUR.jws.IntDate.get('now + 1day');
oPayload.exp = tEnd;
oPayload.iat = tNow;
oPayload.iss = appId;
oPayload.sub = appId;
oPayload.aud = "https://services.poynt.net";
oPayload.jti = generateUUID();
var keyObj = KEYUTIL.getHexFromPEM(keyPrivate);
var sHeader = JSON.stringify(oHeader);
var sPayload = JSON.stringify(oPayload);
var sJWT = KJUR.jws.JWS.sign("RS256", sHeader, sPayload, keyPrivate);
alert(sJWT);
var encodedJWT = sJWT;
var params = { 'grantType': 'urn:ietf:params:oauth:grant-type:jwt-bearer', 'assertion': encodedJWT }
$.ajax({
type: "POST",
url: "https://services.poynt.net/token",
data: JSON.stringify(params),
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
success: function (data) {
alert(data);
},
error: function (e) {
alert(e);
},
headers: {
"api-version": "1.2"
}
});
How am I supposed to access poynt cloud api methods from my javascript client.
Regards,
Shibin