function parseTokenClaims(token) {
  const base64EncodedClaims = token
    .split('.')[1]
    .replace(/-/g, '+')
    .replace(/_/g, '/');

  const chars = atob(base64EncodedClaims).split('');
  const count = chars.length;
  const uriEncodedChars = new Array(count);
  for (let i = 0; i < count; ++i) {
    const c = chars[i];
    uriEncodedChars[i] = '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
  }

  return JSON.parse(decodeURIComponent(uriEncodedChars.join('')));
}
@param {string} token The access token to parse.
@return {AccessTokenClaims} The parsed token claims.