Duplicate api calls on workflows

Hi friends - I’m running into a very strange issue with authorizing an account using Bubble’s API in a custom event.

I am able to post to the 3rd party I’m using to retrieve the user’s “code” which gets displayed on the callback URI in my Bubble app. When I use the api initializer and copy/paste this code, I get a valid response every time, so I know it works.

However, when I trigger a workflow on this page using “if code exists in the URL”, “get code from URL” and trigger the API request as a custom event, I am not receiving a valid response.

I added a step to the custom event that will display the response in a text group on my page and I noticed something very odd: After authorizing on the 3rd party and watching the callback happen in real-time I am seeing the valid response output correctly for a split second and then it changes back to the error above. It’s like the event fires once, succeeds, and the fires again for no reason?

Even stranger still - when I disable the workflow, manually start the authorization process, come back to the callback uri (with the code in the URL), then I re-enable the workflow from the backend, and go back and refresh the front end page ----> it works fine! The request is successful and there’s not a duplicate request. I am able to store the access token as required.

Why would this workflow work correctly when I manually refresh the page but not when the app is loaded in a callback?

image

Hey everyone - in case you land here, the problem was being caused by whatever other ‘onpageload’ workflows I had running on the page that would cause the api to run twice no matter what. To solve the issue I just used a simple blank page as the callbackURI and that worked just fine as expected. Thanks!

Hey, I just experienced this.

I was making an API call to stripe for creating a payment intent within a custom event. It does this, it’s a Bubble bug, I worked around it by making the API call before triggering the custom event, and passing whatever I need in the custom event from the API call as parameters.