javascript - Basic Auth not working in jquery but working in other languages -
i trying authenticate user using basic authentication protocol in jquery keeps giving error:"xmlhttprequest cannot load https://api.credly.com/v1.1/authenticate. request header field authorization not allowed access-control-allow-headers."
but when check api using postman client, works fine.
jquery code:
var settings = { "async": true, "crossdomain": true, "url": "https://api.credly.com/v1.1/authenticate", "method": "post", "headers": { "x-api-key": "myapikey", "x-api-secret": "mysecret", "authorization": "basic "+btoa(<email> + ":" + <password>) } } $.ajax(settings).done(function (response) { console.log(response); });
the api working postman client there should no issue in not working in jquery. please help.
use datatype : 'jsonp'
cross domian request, see also
var settings = { "async": true, "crossdomain": true, datatype : 'jsonp', //cross domain request "url": "https://api.credly.com/v1.1/authenticate", "method": "post", "headers": { "x-api-key": "myapikey", "x-api-secret": "mysecret", "authorization": "basic "+btoa(<email> + ":" + <password>) } }
Comments
Post a Comment