Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supply additional headers with request #67

Closed
robinvdvleuten opened this issue Sep 30, 2016 · 4 comments
Closed

Supply additional headers with request #67

robinvdvleuten opened this issue Sep 30, 2016 · 4 comments

Comments

@robinvdvleuten
Copy link

Hi there,

First, big props for this lib! Very easy to setup 馃憤 I am trying to setup a connection with the discogs oauth api, but they require to send an additional user-agent header. How can I configure this in the grant lib? Here's my setup:

var express = require('express')
var logger = require('morgan')
var session = require('express-session')
var Grant = require('grant-express')

var grant = new Grant({
  'server': {
    protocol: 'http',
    transport: 'session',
    state: true,
  },
  'discogs': {
    key: process.env.DISCOGS_CONSUMER_KEY,
    secret: process.env.DISCOGS_CONSUMER_KEY,
    callback: '/handle_discogs_callback',
  },
})

var app = express()
app.use(logger('dev'))
app.use(session({ name: 'grant', secret: 'very secret', saveUninitialized: false, resave: false }))
app.use(grant)

app.get('/handle_discogs_callback', (req, res) => {
  res.end(JSON.stringify(req.query))
});

app.listen(4000, () => {
  console.log('Express server listening on port ' + 4000)
});
@simov
Copy link
Owner

simov commented Sep 30, 2016

I see, they probably changed how their OAuth flow behaves. I'm going to add this header and a test for it.

Intentionally there is no way to add custom headers, because I want everything non OAuth compliant documented in my code, like this one. Of course this approach can break my code but I prefer it that way.

I'll publish the patch later today.

Thanks for the feedback!

@robinvdvleuten
Copy link
Author

@simov thank for the quick response! I'll wait for the patch then 馃槍

@simov
Copy link
Owner

simov commented Sep 30, 2016

Version 3.6.5 is published with the fix.

Currently the user-agent is non configurable meaning it will always be called Grant during the OAuth flow.

馃帀

@simov simov closed this as completed Sep 30, 2016
@robinvdvleuten
Copy link
Author

@simov thanks! it works as expected 馃憣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants