I need to acquire access token for accessing google sheets api. This is a code inside Next.js page, which is also denoted as 'use client'.
Google api library script is loaded like so:
<Script
src="https://accounts.google.com/gsi/client"
async={true}
/>
Client is being initialized in a function, that is triggered by a button press, so we can be sure, google api library has already been loaded:
let client = window?.google.accounts.oauth2.initTokenClient({
client_id: '[CLIENT_ID].apps.googleusercontent.com',
scope: 'https://www.googleapis.com/auth/spreadsheets',
callback: onSignIn,
auto_select: true,
})
But when window?.google.accounts.oauth2.initTokenClient is called, i get an error in the console:

When i inspect the network tab, i can see that the client_id is not being passed on:

