Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor basic HTTP authentication

Need to connect to an external api: Vogogo.The hard part is converting the curl example into a valid Meteor HTTP.get call. Now here is the code I came up with

apiversionVogogo = 'v3';

Vogogo.listAllCustomers = function() {
    HTTP.get('https://api.vogogo.com/' + apiversionVogogo + '/customers', {
            headers: {
                'Authorization': {
                    user: clientID,
                    clientsecret: apisecret
                }
            }
        },
        function(error, result) {
            if (error) {
                console.log(error);
            } else {
                console.log(result);
            }
        });
    return;
}

The response is an error message:

error_message: 'HTTP Authorization expected"'

Can someone help me rewrite this basic HTTP authentication into a default format? In the docs an example is given with CURL.

curl -X GET 'https://api.vogogo.com/v3/customers' \
 --user clientsecret: \
 -H "Content-Type: application/json"
like image 333
Fullhdpixel Avatar asked Dec 25 '22 16:12

Fullhdpixel


1 Answers

Use the auth parameter in the options field instead of actually setting the Authorization in the headers. From the Docs : auth String HTTP basic authentication string of the form "username:password". You're request would look like:

HTTP.get('https://api.vogogo.com/' + apiversionVogogo + '/customers', { auth : "clientID:apisecret"})
like image 137
Nate Avatar answered Dec 27 '22 06:12

Nate