Forum Academy Marketplace Showcase Pricing Features

Using Third Party API With JWT In Plugin

Hello, I’m creating a bubble API plugin for a third party API. Basically to use bubble as a client app or frontend. The API requires the use of a JWT (Bearer) token for all requests, except for the authentication requests. The authentication request to get an access token accepts basic auth or a token unique to the user (so this would be different for each bubble user in the app). So the flow is this:

  • User logs into bubble, and upon login makes a call with his creds or user token to the authentication endpoint of the API to get an access token.
  • On successful call, store the token and use it for future calls to API.
    — Simple so far, but then then token will expire every 5 mins and needs to be refreshed. Part of the results from the initial auth call are the expiration time of the access token and a refresh token, that can be used to get another access token from a delegation endpoint. So then in addition to above I have:
  • Check current token expiration before making API call
  • If expired, use refresh token to generate a new access token (good for another 5 mins)
  • make the API call

I can make a workflow for a common element in bubble to handler the extra processing before making a call with an “action” endpoint, but not sure how to handle the case of a “data” endpoint attached to an element as its data source. There are some auth options when building the plugin, but none seem to fit this flow exactly, based on what I’ve seen in the editor.

Any thoughts on a best approach would be greatly appreciated. Thanks

1 Like

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