its more of a brute force force approach than built-in way. Brute force has potential to being the place that you iterate – to improve the built-in nature of your implementation.
The JWT spec when combine with bubble’s widely adaptable toolset almost certainly allows for better implements… in theory like below
-
default bubble app has stored app-level token allowing for one year of calls on the api with a scope == bubble.app.${abc} for read access to endpoint==3rdParty.endpoint
call this using api connector that was involved in connector.init() type call at any time up to a year ago
-
error handler on above catches err=token expired which will occur after a year
2.a fallback will RENEW token with same priviledge/scope as above to cover you for year 2
2.b call the auth endpoint ( not the normal api use endpoint ) of the api , parsing the response.token.value and storing that … either store in a client side cookie OR store in bubble db under the User ( logged in user )
2.c for the next year ( until token.exp ) just apply the cookies token value ( the renewed token ) back into the default scenario from #1 above
Discussion - normal auth process for mobile apps works along the above guidelines & implement steps where UX for auth involves a ONE_TIME step of auth that occurs when you install the app… and then user is never bothered by dialog for auth for up to a year when they may once again encounter the dialog over getting renewal on permissions.
that is user level example not example of an entire app being granted permissions on a 3rd party api
built in approach using plugin - renew the token value before expiration
Bubble provides tools / plugin that should ( in theory ) permit scheduled Token renewal on the client ie using a 1 year expiration and renewing the token on 11 month interval with scheduled WF. Token endpoint discussed above would not even be necessary because the bubble plugin permits payload/subject/audience config such that a verifiable token can be generated as needed using the plugin without leaving the client.
The server side endpoint for generating a token is shown below but using the client side shell script at the bottom, a passable token value can be reverse engineered ( and was in bash script ) and that bash gen’d token validated on the server. This demonstrates that with proper docs from the API , in theory, using the bubbles JWT plugins, you can gen your own token using it as required Bearer authorization in standard API auth using tokens.
A bubble JWT client could gen token just as well as the bash shell below