Server side: make http call to external REST API with a certificate to authenticate


#1

Hi

I want to get data from an external API, i would like to authenticate using a .pem or certificate with the meteor http package, is this possible?

In pure node code it looks like this, in the request at the end, they just put the settings object…

var settings = {
			host: hostUri.hostname,
			port: hostUri.port,
			path: hostUri.pathname + '?' + ((hostUri.query) ? hostUri.query + '&' : '') +  'xrfkey=' + xrfkey,
			method: method,
			headers: {
				'X-Qlik-Xrfkey': xrfkey,
				'X-Qlik-User' : 'UserDirectory= WINDOWS2012; UserId= qlikservice ',
				'Content-Type': 'application/json'
			},
			pfx: cert,
			passphrase: options.PassPhrase,
			rejectUnauthorized: false,
			agent: false
		};
		
		//Send ticket request
		var req = https.request(settings, function (res) {

Thank you


#2

You can indeed. It’s in the docs http://docs.meteor.com/api/http.html#HTTP-call

You want the npmRequestOptions option, which is options to pass to the request library that Meteor HTTP uses in the background. See https://github.com/request/request#using-optionsagentoptions for the relevant options for authenticating with a certificate.


#3

Thank you so much!! …
Btw, you would really make my day if you also know the answer for my strange issue with the dropdown box.