Closed m-salamon closed 5 years ago
jwtFromRequest accepts a function. You could write a custom function to do this.
Something like
const myFunction = (req) => {
const urlQueryParam = ExtractJWT.fromUrlQueryParameter('secret_token')(req);
return urlQueryParam != undefined
? urlQueryParam
: ExtractJWT.fromHeader('secret_token')(req);
};
options.jwtFromRequest = myFunction;
@DanielSwiegersServian is right: A custom extractor function is the way to do this. If you want to contribute a composite extractor that accepts a list of extractors and runs them in order until one returns a valid JWT, please feel free to do so. Be sure to include unit tests!
I would like to use 2 extraction methods for various types of requests.
Something like this: (it does not work)