Pass token on query string / allow passing custom getToken function
See original GitHub issueIt would be nice to allow passing the token on the query string (?token=....
) instead of having to passing it as a request header. express-jwt permits this by allowing you to pass a custom getToken function like so:
app.use(jwt({
secret: 'hello world !',
credentialsRequired: false,
getToken: function fromHeaderOrQuerystring (req) {
if (req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer') {
return req.headers.authorization.split(' ')[1];
} else if (req.query && req.query.token) {
return req.query.token;
}
return null;
}
}));
Issue Analytics
- State:
- Created 8 years ago
- Comments:19 (8 by maintainers)
Top Results From Across the Web
How can I use a token from a request for other requests after ...
Token = GetToken(Request);//Made into a separate function in the inherited class _backgroundTaskQueue.StartTask(request); return Ok(new ...
Read more >Deprecating usage of token as a query string parameter in ...
On February 24, 2021 we will stop allowing newly created apps to send token query string parameters. Need any help? Let us know!...
Read more >Authentication and authorization in ASP.NET Core SignalR
When using WebSockets and Server-Sent Events, the token is transmitted as a query string parameter. Built-in JWT authentication. On the server, ...
Read more >Access Tokens - Auth0
The passed token informs the API that the bearer of the token has been authorized to access the API and perform specific actions...
Read more >JSON Web Token Tutorial using AngularJS & Laravel - Toptal
In order to do this, the request Authorization header or query string needs to provide ... This is passed to the controller via...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the reminder, @nfantone 😃 I‘ve merged it and published 1.2.0.
Thanks for the contribution, @danwkennedy!
I’m gonna leave it. You could do something similar inside of the getToken function (i.e. check this or check that)