Running API workflow for user (oAuth2 User-Agent flow) while not logged in?

You cannot force Bubble to update the access_token. Bubble refresh it when needed.

If you are trying to fetch data on behalf of user but without this user to be logged in and without scheduling a backend WF from this user session, it won’t work. Also, if you are trying to fetch data from this user (example a calendar) to show to another user, it won’t work (will work until token expire)

Maybe you can explain exactly what you are trying to do and why you need access token this way?

Sure! here is what i am trying to do:
I want to enable users to sign and log in using Microsoft or google, since i am providing features for those services. Users ultimately need to connect their accounts to access a core feature. However, to build this feature I needed to use api calls, that required tokens like access tokens etc. Hence, I build the oAuth2 manually, because the regular bubble-provided oAuth-flow had the drawbacks of constantly requiring me to re-connect my account as soon as the access token expired. I judged this was not a good user experience and decided to rebuild it manually. However, the manual approach also came at a great cost: losing the ability to sign users up or log users in using their social media accounts. So right now, creating a new a account and connecting to my core features requires 2 separate logins, which is also terrible for the user experience.
My options are to either manually create an account when a user signs up with a social network and i cannot find this particular id or email address, but then i also need to assign a password and change the email. If I log the user in again I also need a password.
The other appraoch would be to try to fetch the code from bubble’s oAuth2 flow and run the token endpoint call myself and feed the response back into the ‘User profile endpoint’. So instead of the bubble flow calling the token endpoint it would call my api, which runs the access & refresh token request and would have to return it in the correct response format for the workflow to continue as regular.

Generally, just creating a new account manually and assigning a random password would be the easiest solution, but also not very secure.

When? when user use your app? Just add more call to the API where you set user-agent flow!

This is only for you in API connector. Bubble doesn’t refresh API token for API connector. But will do it for any user. Just test it! you shouldn’t be logged out and need to reconnect and approve your app again. I’m actually logged in to an app since like 2 weeks. This is using Google oauth2. And when I need to reauthenticate, It’s doesn’t ask me to authorize app again.

Even if I don’t recommend, you can create user with email from Gmail or MS and a password generated from API data (like userID and some more informations that will be hard to guess and hashed). However, I think the best instead is to use Bubble auth and add API connection with the manual process (and save token and refresh info with the user profile)

so that appraoch woked. Just redirect the auth token to your own api and return the authentication api call as text.