Skip to content

Instantly share code, notes, and snippets.

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 chuckreynolds/1ce45e5e0d985c8383d4eeff09f0f8f2 to your computer and use it in GitHub Desktop.
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
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