Forum Academy Marketplace Showcase Pricing Features

Saving and Updating User Access Tokens

Hi everyone,

I have been using the API Connecter to connect to Facebooks Marketing API. I am able to sync in with socials using this API which syncs personal data (Marketing API - Documentation - Facebook for Developers) only when the other users are added as developers to the Facebook app (not been able to get this working for a new users which isn’t added as an admin or developer to the Facebook app). But I also am having an issue even with users added as admins/developers to the Facebook App, which is that the access token I have manually added in the API connecter as it is the only way to make the calls and posts work. This access token is obviously for only one users. So my questions are…

  1. How can I request an access token from FB with all necessary scopes and safe it in Bubble so it can be added as a parameter to the end of each call/post/delete?
  2. How can I have Bubble.io know that an access token is expired so that the user can re-sync with Facebook and allow permissions
  3. How can I have the app work with users who are not added to the Facebook app as a developer or admin (this maybe a question better suited for Facebooks API forum but any guidance would be super helpful!)

I have added screenshots of how I currently have the API calls set up, but ideally the access_token needs to be dynamic.



For some reason the personal call doesn’t need an access_token and it returns the right personal information for different Facebook users (but only when they are added as a developer or admin to the Facebook App). but the create automation call which uses Facebooks Marketing API, needs an access_token added or it will come up with an error saying it requires an access token, so I need to add one in a dynamic way so that I can save users access tokens and load them as a parameter for each call.

Hello @julesskinner1998

Uncheck private for the access token. This parameter should now show up in the action so that you can make it dynamic.

Ah yes thank you!

And now is there a way to save the users access token so it can be loaded dynamically. And also if the access token returned an “expired” message to run a workflow to request another access token to replace the expired one?

1 Like

Hello @julesskinner1998

  1. Save access tokens in the dB (in the relevant object) that way you can use them when needed in backend flows
  2. Better to program a perpetual refresh token flow prior to expiration. When a token has expired you need to restart the process which with oAuth starts with the user re-authorizing again.