async function getToken(auth) {
  const url = auth.tokenUrl || defaultTokenUrl;
  const body = new URLSearchParams();
  body.append('grant_type', 'client_credentials');
  body.append('client_id', auth.clientId);
  body.append('client_secret', auth.clientSecret);

  /**
   * @type {RequestInit}
   */
  const options = {
    method: 'POST',
    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
    body,
  };
  const response = await fetch(url, options);
  if (!response.ok) {
    if (response.status === 401) {
      throw new Error('Bad client id or secret');
    }
    throw new Error('Failed to get token');
  }
  const data = await response.json();
  return data.access_token;
}
@param {AuthConfig} auth The authentication configuration.
@return {Promise<string>} The authentication token.