Plugin Development Question

I have done various development on zapier, make, pabbly for custom apps. Each of them allows you to save additional authorization fields. The API I am building requires a few things in addition to the normal OAuth2 process. It requires me to save a hashed Id value for the specific company you are connecting to. This value is used in a variety of API calls, but not in every API call. It is sometimes used in the body and sometimes used in a query parameter. Sometimes it isn’t used at all. I set it up under “additional keys” as this made sense for the use case. Lets just call it “myId”.

The question is: how do I reference this new key “myId” I created in the additional authorization? And how does bubble prompt them to fill it in? The docs say this: " These keys will be made accessible in the context object that is sent to all the functions used in your elements and actions (see the following sections for more details)."

The next section doesn’t explain the context object and how it is referenced. I also will need to collect the email address in order to initialize things. My connection works fine when I hardcode these ids and emails in both the API connector and the plugin builder, but obviously the goal is to make a plugin that others can use.

-Jacob

The keys can be accessed in the Elements tab in any function that has “context” as a parameter, like the “initialize” function.
Screenshot 2023-04-05 at 10.54.31 AM

there you could say “context.keys.myId” and that would reference the key

I wonder why you don’t use a mix of manual process + API Connector? Actually, I don’t see any reason to create a plugin for what you describe.

2 Likes

Because I want to sell access to it.

Very helpful for actions inside the elements. What I am referring to is using it in the actual API calls. So for example:

base url /contacts/?myId=[myId]

Also, when I set this connection up in the API connector I get this: “Your token is not valid any more. You should sign up again in run mode to get a token to set up and modify your calls”. So is the API connector app not managing access and refresh tokens? I don’t want to re-authorize it every 24 hours. I started working on the plugin version because I am concerned on the token refresh.

As I read through those guides I see a lot of people commenting the API connector isn’t refreshing the tokens. Is that a fact? As in: is bubble not actually saving the access and refresh tokens and managing it on their backend?

It’s context.keys[‘myId’]

So if you pass a token via url (which you shouldn’t) it would be

const baseUrl = ‘https://some url.com/yo’
cont reqUrl = {template literal}baseUrl?my_id=${context.keys[‘myId’]}{template literal}

2 Likes

I am going to revive this thread to see if I can get a few direct answers from the actual bubble dev team.

Question 1: Does the bubble plugin actually save the OAuth2 access and refresh tokens in their database and automatically refresh the token? The headline for plugins says it is for “REST API”

Question 2: Does the API connector actually save and refresh the OAuth2 tokens? My research and testing says that is a no and its a one time thing used for temporary OAuth2 logins.

I see the threads on these silly hack workarounds of using your internal workflow builder to refresh tokens. I would like to see a definitive answer so that I can plan accordingly with a private server to handle the tokens.