Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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