Grafana k6 with googleapis

I was able to manually create the googleapis method using k6/http package. I am able to get access token using this

const payload = `client_id=${clientId}&client_secret=${clientSecret}&refresh_token=${refreshToken}&grant_type=refresh_token`;
  
  const tokenResponse = http.post(tokenUrl, payload, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  });
  
  const accessToken = tokenResponse.json().access_token;

I now need to access the mail inbox to fetch a mail

const options = {
      url: 'https://gmail.googleapis.com/gmail/v1/users/test.tests@gmail.com/messages',
      params: {
        q: `from:no-reply@rework.link to:${profilesEmailAddress}`,
      },
      headers: {
        Authorization: `Bearer ${accessToken.access_token}`,
      },
    };
    const response = http.get(options.url, options.params, options.headers)

So I am using the http.get() to access the mail. But this isn’t working, I am getting status code 401. The same logic is working in postman to get a response. Why isn’t it working here?It would be much helpful if someone can solve this problem.

Thanks.