Accessing Google ID Token via Client-Side JavaScript in Next-Gen App after Google SSO Login?

Hi Fellow Knacksters,

I’m working with a Next-Gen application where users log in via the configured Google SSO integration.

Goal:

After a successful Google SSO login, I need to obtain the user’s Google ID Token within my client-side JavaScript. This token is required to securely authenticate requests from the user’s browser to a private, external API

What I’ve Tried:

I’ve been exploring the Knack object in the browser’s developer console after a user logs in via Google SSO:

  1. Inspecting Knack Object: Using console.dir(Knack), I looked through the available properties (user, auth, session, etc.) but couldn’t locate a property that clearly holds the Google ID Token.

  2. Using Knack.getUser(): I called await Knack.getUser(). This function successfully returns an object with user details (ID, email, name) and a token property. However, upon inspecting this token (it’s a JWT starting with eyJhbGciOiJIUzI1Ni...), it appears to be a Knack-specific session token, not the Google ID Token required for authenticating with Google Cloud services.

My Question:

Is there a documented or known method within the Next-Gen JavaScript environment to access the Google ID Token for the currently authenticated user after they have logged in using the Google SSO feature?

Specifically, how can my client-side code retrieve this token to be used in an Authorization: Bearer <ID_Token> header for calling an external Google-authenticated API?

Any pointers, examples, or insights would be greatly appreciated!

Thanks,

Gui
Fine Mountain Consulting


update on this:

I was able to find this in the global variables. So I did the await getGoogleIdToken() and it throws a modal that says “ error: googleID Token retrieval needs to be implemented. Please contact support”

I have started that conversation and will update here when I know more.

scratch this… that was MY code :slight_smile: