Skip to content

Instantly share code, notes, and snippets.

@medisoft
Created April 14, 2019 18:07
Show Gist options
  • Save medisoft/707767ec680825a249c58035cbe6f833 to your computer and use it in GitHub Desktop.
Save medisoft/707767ec680825a249c58035cbe6f833 to your computer and use it in GitHub Desktop.
const auth = () => {
let token;
if (secrets.length > 0) {
const idx = Math.floor(Math.random() * secrets.length);
token = jwt.sign({ key: secrets[idx].API_KEY, nonce: moment().valueOf() }, secrets[idx].API_SECRET);
} else {
token = jwt.sign({ key: API_KEY, nonce: moment().valueOf() }, API_SECRET);
}
return { 'Authorization': `bearer ${token}`, 'Content-Type': 'application/json' };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment