Creating or logging in user after OAuth flow

Hi Everyone, new to Bubble and hoping to get help with users after OAuth.

I have an App which fetches data from HubSpot via API. I want users to click a button to connect HubSpot to Bubble and then if that user already exists, sign them in, if not then create a user. Then I can link data from their HubSpot account to their user and run API calls to HubSpot.

I have manually configured the APIs so that they can click a button, this sends to the private HubSpot app and a code is returned. The code is then used to obtain the access and refresh token. Here I am stuck. If I create an action to sign-up or login then I need to provide a username (which I can get using an API call to fetch token metadata) and a password (which they have not set and which is not fetched from HubSpot after they login?

Should I ask users to sign-up or login first, THEN click the button to connect HubSpot and update the logged in user record with then tokens returned from HubSpot? Any help would be much appreciated!

Do you have the ability to get their email from HS?

If so, generate a password for them and then allow them to sign in via a login form. Similar to magic link.

Or, do the second method you suggested.

Cheers for the response Timbo! Yes I can get their email from HubSpot, I was hoping I could allow them to sign-in to HubSpot and then use those credentials to log them directly into Bubble but if not I will go with option 2. Thanks!

have a check to see if there is any special codes or info you can get thats unique to that user which never changes. use that as a password. I do this with a web3auth wallet system and get the unique identifier as the password as it never changes.