Skip to content

Conversation

@lindsey-volta
Copy link
Contributor

@lindsey-volta lindsey-volta commented Sep 24, 2025

Migrate to the Google Identity Services (GIS) library from the Google Sign-In JavaScript library.

  • onInitialClientRender.js

    • Load Google JavaScript API Client https://apis.google.com/js/api.js for interacting with the APIs
    • new Load Google Identity Services client https://accounts.google.com/gsi/client for handling authentication
    • new Checks localStorage for a non-expired token and restores user's session if found
    • Loads the discovery documents for the Google Analytics Data and Admin APIs
    • removed Loading the discovery documents for the Analytics Reporting API v4 (UA)
    • new Initializes a tokenClient from GIS library. This client is responsible for handling the OAuth 2.0 flow.
    • new The callback function is executed when the user successfully authenticates. It receives a token response, which includes the access_token. The token is then:
      • Saved to localStorage
      • Set on the gapi client for use in subsequent API requests
      • Stored in the application's global state
  • useLogin.ts

    • Determines userStatus based on presence of the access token
    • Calls TokenClient.requestAccessToken() in the login method (replaces gapi.auth2.getAuthInstance().signIn())
    • Calls google.accounts.oauth2.revoke() in the logout method (replaces gapi.auth2.getAuthInstance().signOut())

window.gapi.load("client:auth2:analytics", () => {
Promise.all([
window.gapi.client.load(
"https://analyticsreporting.googleapis.com/$discovery/rest?version=v4"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can now remove the loading of the Analytics Reporting API v4 discovery document since it looks like it was for Universal Analytics accounts only and is no longer used in the project (searched for gapi.client.analyticsreporting)

@lindsey-volta lindsey-volta marked this pull request as ready for review September 25, 2025 20:37
@lindsey-volta lindsey-volta merged commit 57277fc into main Sep 25, 2025
7 checks passed
@lindsey-volta lindsey-volta deleted the migrate-gis branch September 25, 2025 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants