Skip to content

Instantly share code, notes, and snippets.

View jakeashcraft's full-sized avatar

Jake Ashcraft jakeashcraft

View GitHub Profile
@jakeashcraft
jakeashcraft / postman-pre-script-oauth2.js
Last active November 30, 2022 08:53
Postman Pre-request Script used to automatically retrieve a new OAuth2 token when the token is expired
pm.expect(pm.globals.has('accessToken')).to.be.true;
const sdk = require('postman-collection');
const JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;
const currentToken = pm.globals.get('accessToken').replace('Bearer ', '');
const path = pm.environment.get('url') + '/auth/token';
let expired = true;
if(currentToken && currentToken.length > 0) {
@jakeashcraft
jakeashcraft / 0_reuse_code.js
Created May 29, 2014 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console