Skip to content

Commit

Permalink
Allow optional headers to the requests
Browse files Browse the repository at this point in the history
The above change allows an extra "headers" config options. This is necessery for example for the FreeAgent API that requires a User-Agent header

You can then use it like this:

    var oauth2 = require('simple-oauth2')({
        clientID: 'SOMEID',
        clientSecret: 'SOMESECRET',
        site: exports.'SOMEURI',
        tokenPath: '/token_endpoint',
        authorizationPath: '/approve_app',
        headers: {'User-Agent' : 'require'}
    });

Note: ReadMe should reflect this
  • Loading branch information
nsarris committed Aug 20, 2015
1 parent f02b9be commit ac56306
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ module.exports = function(config) {
options.headers = { 'Authorization': 'Basic ' + new Buffer(config.clientID + ':' + config.clientSecret).toString('base64') }
else
options.headers = {}

if (config.headers instanceof Object)
for(var header in config.headers)
options.headers[header]=config.headers[header];

if (config.ca)
options.ca = config.ca;
Expand Down

0 comments on commit ac56306

Please sign in to comment.