Skip to content

Instantly share code, notes, and snippets.

@trotzig
Created January 26, 2018 12:52
Embed
What would you like to do?
JWT creation for happo.io
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