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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -