Fullhdpixel
Fullhdpixel

Reputation: 813

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"

Upvotes: 4

Views: 2579

Answers (1)

Nate
Nate

Reputation: 1875

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"})

Upvotes: 10

Related Questions