Skip to content

Auth prescript for SG request api

Prescript

js
const options = {
  url:  'https://<YOUR_STUDIO>.shotgunstudio.com/api/v1/auth/access_token', 
  method: 'POST',
  header: {
    'Accept': '*/*',
    'Content-Type': 'application/x-www-form-urlencoded',
  },
  body: {
    mode: "urlencoded",
    urlencoded: [
        { key: "grant_type", value: "client_credentials"},
        { key: "client_secret", value: "<CLIENT_SECRET>"},
        { key: "client_id", value: "<CLIENT_ID>" },
    ]
  }
};

pm.sendRequest(options, function (err, response) {
    const json_response = response.json();
    const new_access_token = json_response.access_token;
    pm.variables.set('access_token', new_access_token);
});

// use {{access_token}} in bearer token field

JSON as request body

js
// json as body
 body: {
    mode: "application/json",
    raw: JSON.stringify(
        {
            key:"<VALUE>",
            anotherkey: "<VALUE>"
        })
  }