Skip to content

Commit c537d5e

Browse files
committed
Add hootsuite to the list of providers that require basic auth
1 parent 4bef2bb commit c537d5e

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

lib/flow/oauth2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ exports.access = (provider, authorize, session) => new Promise((resolve, reject)
7878
client_secret: provider.secret
7979
}
8080
}
81-
if (provider.ebay || provider.fitbit2 || provider.homeaway || provider.reddit) {
81+
if (/ebay|fitbit2|homeaway|hootsuite|reddit/.test(provider.name)) {
8282
delete options.form.client_id
8383
delete options.form.client_secret
8484
options.auth = {user: provider.key, pass: provider.secret}

test/flow/oauth2.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -262,37 +262,37 @@ describe('oauth2', () => {
262262
before((done) => {
263263
var config = {
264264
defaults: {protocol: 'http', host: 'localhost:5000', callback: '/'},
265-
basecamp: {}, concur: {}, ebay: {}, fitbit2: {}, homeaway: {},
266-
reddit: {}, shopify: {}, smartsheet: {}, surveymonkey: {}, visualstudio: {}
265+
basecamp: {access_url: url('/access_url')},
266+
concur: {access_url: url('/access_url')},
267+
ebay: {access_url: url('/access_url')},
268+
fitbit2: {access_url: url('/access_url')},
269+
homeaway: {access_url: url('/access_url')},
270+
hootsuite: {access_url: url('/access_url')},
271+
reddit: {access_url: url('/access_url')},
272+
shopify: {access_url: url('/access_url')},
273+
smartsheet: {access_url: url('/access_url')},
274+
surveymonkey: {access_url: url('/access_url')},
275+
visualstudio: {access_url: url('/access_url')},
267276
}
268277
grant = Grant(config)
269-
var app = express().use(grant).use(bodyParser.urlencoded({extended: true}))
270-
271-
grant.config.basecamp.access_url = url('/access_url')
272-
grant.config.concur.access_url = url('/access_url')
273-
grant.config.ebay.access_url = url('/access_url')
274-
grant.config.fitbit2.access_url = url('/access_url')
275-
grant.config.homeaway.access_url = url('/access_url')
276-
grant.config.reddit.access_url = url('/access_url')
277-
grant.config.smartsheet.access_url = url('/access_url')
278-
grant.config.surveymonkey.access_url = url('/access_url')
279-
grant.config.visualstudio.access_url = url('/access_url')
280-
281-
app.post('/access_url', (req, res) => {
282-
if (req.headers.authorization) {
283-
res.writeHead(200, {'content-type': 'application/x-www-form-urlencoded'})
284-
res.end(qs.stringify({basic: req.headers.authorization}))
285-
}
286-
else if (req.url.split('?')[1]) {
287-
res.writeHead(200, {'content-type': 'application/json'})
288-
res.end(qs.stringify(req.query))
289-
}
290-
else if (req.body) {
291-
res.writeHead(200, {'content-type': 'application/x-www-form-urlencoded'})
292-
res.end(qs.stringify(req.body))
293-
}
294-
})
295-
server = app.listen(5000, done)
278+
server = express()
279+
.use(grant)
280+
.use(bodyParser.urlencoded({extended: true}))
281+
.post('/access_url', (req, res) => {
282+
if (req.headers.authorization) {
283+
res.writeHead(200, {'content-type': 'application/x-www-form-urlencoded'})
284+
res.end(qs.stringify({basic: req.headers.authorization}))
285+
}
286+
else if (req.url.split('?')[1]) {
287+
res.writeHead(200, {'content-type': 'application/json'})
288+
res.end(qs.stringify(req.query))
289+
}
290+
else if (req.body) {
291+
res.writeHead(200, {'content-type': 'application/x-www-form-urlencoded'})
292+
res.end(qs.stringify(req.body))
293+
}
294+
})
295+
.listen(5000, done)
296296
})
297297

298298
describe('web_server', () => {
@@ -319,7 +319,7 @@ describe('oauth2', () => {
319319
})
320320

321321
describe('basic auth', () => {
322-
;['ebay', 'fitbit2', 'homeaway', 'reddit'].forEach((provider) => {
322+
;['ebay', 'fitbit2', 'homeaway', 'hootsuite', 'reddit'].forEach((provider) => {
323323
it(provider, async () => {
324324
grant.config.ebay.key = 'key'
325325
grant.config.ebay.secret = 'secret'

0 commit comments

Comments
 (0)