Created
September 25, 2019 01:25
-
-
Save acfatah/b7387e72f8cc48e1993e31534bcc9479 to your computer and use it in GitHub Desktop.
Authorization Bearer Token Parser Function For Express
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default request => { | |
let parts = request.headers.authorization.split(' ') | |
if (request.headers.authorization && parts[0] === 'Bearer') { | |
return parts[1] | |
} else if (request.query && request.query.token) { | |
return request.query.token | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment