MomenSherif / react-oauth

Google OAuth2 using the new Google Identity Services SDK for React 🚀
https://www.npmjs.com/package/@react-oauth/google
MIT License
1.13k stars 141 forks source link

Page refresh removes access_token from gapi api calls. #325

Open matheusbaumgart opened 10 months ago

matheusbaumgart commented 10 months ago

I use gapi and when I refresh the page future calls to gapi will not have the authorisation token to it. They all have right after I authenticate, but if I refresh, it's gone. I already tried setting the token after login, no luck.

window.gapi.client.setToken({ access_token: <ACCESS_TOKEN> })

window.gapi.auth.setToken({
    access_token: "YOUR_TOKEN_HERE"
});

Any clues @MomenSherif?

stippi2 commented 10 months ago

It's more or less expected, I would say. But I would like to rephrase the question. My project is currently in "Test" mode, and the only Javascript origins I specified are "http://localhost" and "http://localhost:5173". From inspecting the cookies, it looks like a session is stored.

Here is the quesion: Is it somehow possible to skip the prompt when reloading the page and get an auth-flow based on the previous session, resulting in a new access token?