Skip to content

Instantly share code, notes, and snippets.

@trotzig
Created January 26, 2018 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trotzig/7202a5a3b03985f265beb80679baf02f to your computer and use it in GitHub Desktop.
Save trotzig/7202a5a3b03985f265beb80679baf02f to your computer and use it in GitHub Desktop.
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