How to get the user access token

Hi,

I have an iOS wrapper that loads our bubble web app. The Bubble app starts on the login page. After the user fills in the username ans password and clicks on the login button i start the workflow with an action “log the user in”. then the user is logged in. The user can now activate native elements from the iOS wrapper that can save content into the bubble database. But if the wrapper want to save the content into the database thru an API call, it needs the user token.

I know that i can get the user access token when i send an post call to an backend workflow API with the “log the user in” action. in the respond i get the user token, but that only works when i call this API workflow from another location (postman, external app etc) i don’t get the token when i call the (scheduled) API workflow after the login button is clicked.

Is it possible to get the user token after the client side login action? so i can send the user token to the wrapper after the “log the user in” action. Or do I need to provide the username and password to the wrapper, and should the wrapper independently make its own call to the login API endpoint?

Yes but only with a workaround of saving the token in the db. There are a few posts on that.

1 Like

I have created a API call with the Bubble API connector and sending a POST request the a backend workflow “login” in there i run the action “log the user in” and now i get an response with an token that i can save into the database.

But when i refresh the page the user is not logged in so i also need to run the “log the user in” action on the client side with the same credentials. now i have to check if i still can use the token i got from the API call because on every login action the user token changes. I don’t know if i can use different tokens for the same user?

To login on the client side, you just need a magic link and direct the user to that page. If stay logged = yes then user will continue to be logged in. but even if it isn’t the user will remain logged in for entire session.

1 Like


Logging in the user the second time doesn’t necessarily invalid the previously generated token



Using the option recommended you’ll have both token to use in subsequent calls and the magic link to login client side

All possible by a simple get call. You can add password and email in a post call. I used Get as the password was manually input.

2 Likes

I can assure you your feedback is not helpful. Point where a step is unnecessary to help the user asking the question. Anyway in the spirit of constructive community contributions I’ll state .

  1. Magic Link is for Front- End login

  2. Token is for subsequent Data API calls.
    If Magic Link is not necessary then delete the step and remove it as a variable in the returned data.

Hopefully that helps.

1 Like

Above step I sent is indeed using postman an external app. You can as well use the API connector as postman substitute. I’ve done that in the past and see no issue.

1 Like

Thanks for your explanation. It works now! i use the Bubble API connector to call the “login” API workflow, and i send the response token to the wrapper.

Do you know why is it not possible to get the token when you call that “login” API endpoint with an scheduled workflow action? That would be much easier.

I’m not sure why, it is just a Bubble setup so I think they should allow us to return data in future updates. Reading through the documentation use case is sending an email in 2 weeks time so I think that’s where it works best. The option “Expose as a public API workflow” seemed to be an after thought that allow us to schedule only immediately. Hence introduction of Return Data from API

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.