Created
January 20, 2022 00:34
-
-
Save chuckreynolds/1ce45e5e0d985c8383d4eeff09f0f8f2 to your computer and use it in GitHub Desktop.
Postman Collection Pre-Request script to get access token for Wikimedia Enterprise Auth
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
const wmeAuthUrl = 'https://auth.enterprise.wikimedia.com/v1/login'; | |
const wmeUsername = pm.collectionVariables.get("wmeUsername"); | |
const wmePassword = pm.collectionVariables.get("wmePassword"); | |
const getTokenRequest = { | |
method: 'POST', | |
url: wmeAuthUrl, | |
header: 'Content-Type:application/json', | |
body: { | |
mode: 'application/json', | |
raw: JSON.stringify( | |
{ | |
username: wmeUsername, | |
password: wmePassword | |
}) | |
} | |
}; | |
pm.sendRequest(getTokenRequest, (err, response) => { | |
const jsonResponse = response.json(); | |
const newAccessToken = jsonResponse.access_token; | |
pm.variables.set('access_token', newAccessToken); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment