Can we set and use collection variables in K6?

So I have set a collection variable as follows:

  function accessTokenRequest() {
    let response = http.post(url, payload, { headers: headers });
    let responseBody = JSON.parse(response.body);
    pm.collectionVariables.set(
      "access_token",
      `Bearer ${responseBody.access_token}`
    );
  }
  accessTokenRequest();

In a seperate login script that I use. Then I use this variable in my K6 script as the value for the Authorization header:

Authorization: "{{access_token}}",

When I start running my script however, I get the following error:
ERRO[0005] Error: May only be used in a request scope
And the pm.collectionVariables.set() function is the one referred to. Which would imply we cannot set collection variables from the responsebody and very problematic for our rollout.

The request itself does return a 200.