Forum Academy Marketplace Showcase Pricing Features

Client side data store var in user table

I have an API that needs to get a token on the client side (The token is returned based on the browsers cookies.) and then use that token in all future requests to the API using the API Connector. I can’t find a way to store something in bubble’s user database from the client side… I have looked into making a custom javascript plugin that would AJAX the API and get the token too but I can’t find a way to store something for a user from the client side… This also wouldn’t need to be stored if there was a way to just use a client side javascript var in API Connector requests…

If the API connector would support actions from the client side this wouldn’t be needed.(The documentation has said that is coming soon for a long time.)

Any ideas?

How do you create the token actually?

The token is a cryptographic authentication token that allows 24 hours of API access for the user. It is created by the API after the API validates the user. On future API calls that include this token the API returns user specific data and allows user actions that are authenticated. The user must have the client side cookies or this token to make these requests. The token is a string that is around 60 chars long.

So why don’t you save it in DB?

That is a good idea but since it is only returned to a client originated request I can’t seem to find a way to do that? How can I save it to the db?

Can you share your actual settings?


This is the API connector settings…
The problem is that I can’t get the data from a client side call into the the DB. That would be one way of solving this if you know a way. If it try to do something on the server than it will make the call from the server and the token won’t be returned…

The documentation for browser calls is here…
https://manual.bubble.io/core-resources/bubble-made-plugins/api-connector#allow-call-to-run-directly-in-the-browser

The call is performed client side if possible, but if you use it somewhere else, it will be processed server side.
Anyway this is not really important. you could choose to use it in the field where you want to store it like Current user’s token using Get data from APi and use this api call to get the token and store it in DB or you can change it to action and the payload will be returned. So you can make change to current user using result of step 1 token