Hi there. I need to call an external API that will then create new resources within Bubble. These resources have privacy settings that only allow them to be created by an authenticated user. The API doesn’t know who the user is, so I need to pass this from Bubble together with other request parameters.
Questions:
How do I get the current user’s auth token?
How do I call my API from a user’s action, passing the token and other dynamic data?
This thread where I muse in real-time about this is somewhat out of date, but will probably inspire you a bit. (Consulting the updated docs about this would help you too.)
I don’t have an example of this but you would build an authentication endpoint in your app (which could now be either a GET or POST) and that would return the authentication token and then that can be used by the next webhook. Alternatively if such a facility is not available, you could pass the users credentials to an endpoint that logs the user in, gets the auth token then does whatever you need the Data API to do and returns the right values.
Anyway, links to the docs are included in the thread. I can’t think of a more helpful explanation than this, even though it’s not an absolute answer.
Whether you can do this entirely programmatically depends on a lot of different factors.
And, Obvs, if the user is present and logged into your app, this is much easier (this seems to be implied in your original question), and in that case you can do this entirely programmatically.