Created
January 26, 2018 12:52
-
-
Save trotzig/7202a5a3b03985f265beb80679baf02f to your computer and use it in GitHub Desktop.
JWT creation for happo.io
This file contains 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
import request from 'request-promise-native'; | |
import jwt from 'jsonwebtoken'; | |
export default function makeRequest(requestAttributes, { apiKey, apiSecret }) { | |
const signed = jwt.sign({ key: apiKey }, apiSecret, { header: { kid: apiKey } }); | |
return request( | |
Object.assign({ | |
auth: { | |
bearer: signed, | |
}, | |
}, requestAttributes), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment