In my walkthrough, I’ve highlighted with smiley emojis , points which I do not understand why it does not work from a Bubble perspective.
The link to the development version: http://app.rewardnation.co/version-test/install?debug_mode=true
tldr:
- An Unhandled Error Occurs event doesn’t catch a workflow error, am I doing something wrong?
- Backend Workflow Page Redirect(302) Response Type does not redirect, why?
- Is there any way for the Backend Workflow to communicate with the Client on when it’s completed running or whether it’s successful?
Objective : I’m trying to build a manual OAuth with Slack because the BubbleSlack plugin doesn’t give me the scopes that I require.
Approach :
-
There’re 2 API calls that are used, 1 to get the Access Token and the other to get the User’s Profile Information. Kudos to @ambroisedlg and his well written guide on OAuth
-
The User goes to the Install page and clicks on the Slack Manual OAuth button, for clarity, I’ve labelled it
-
This triggers the relevant Workflow, which directs them to the Slack_OAuth_Redirect page
-
On the Slack_OAuth_Redirect page, 1 of the 2 Page Load Workflows will trigger: Page Load Slack Authorization
-
After the User authorizes on Slack, they are redirected back to Slack_OAuth_Redirect and the other Workflow triggers: Page Load Slack Access Token
Page Load Slack Access Token is the Workflow that I’m having issues with. I would like to:
- Sign the User Up (And catch the edge case where an existing User tries to Sign Up)
- Log the User In
- Redirect back to the Install page
In the above screenshot that there are 2 other Workflows highlighted in Red. These are Test Slack Sign Up API and Test V2 Slack Sign Up API . They are alternative approaches that I’ve taken to try to solve my problem.
Privacy Rules for the User Type is shown in (Screenshot 6).
Problems:
Problem 1: Page Load Slack Access Token
This works and the User successfully Signs Up, Logs In, and gets redirected to the Install page. However, this does not handle the case scenario where an existing User tries to Sign Up through the same Workflow. This throws a Workflow error, as shown in below screenshot.
I’ve tried to solve this issue in 2 ways:
-
Using An Unhandled Error Occurs event . This somehow doesn’t work, even though it works fine for us on an email/password Sign Up page.
-
Using Only When in the Sign the User Up event. I understand this doesn’t work because of the Privacy Rules that exist, and since the Current User isn’t Logged In, is unable to conduct a search for Users.
Since the Page Load Slack Access Token didn’t work, I tried moving the Sign Up flow to a Backend Workflow instead.
Problem 2: Test Slack Sign Up API
According to the Server Logs, this works too. The User successfully Signs Up and Logs In. By clicking on Ignore Privacy Rules, the edge case of an existing User Signing Up is detected and bypassed to allow the existing User to Log In instead.
I detect the Log In event through a Console Log, where the Current User’s email is printed.
But the User does not get redirected and remains on the Slack_OAuth_Redirect page. I’ve tried to solve this issue in 2 ways:
- By configuring the Response Type of the Backend Workflow to be Page Redirect(302) , as per my original screenshot.
This somehow doesn’t work as intended. From my understanding of this forum post by @emmanuel, once the Workflow completes, the redirect should trigger, regardless of success or failure and the User should thus be redirected to the respective success / failure pages. However in my application, the User remains on the Slack_OAuth_Redirect page.
- By implementing several different ways of redirection upon User becoming Log In in the Slack_OAuth_Redirect page’s Workflows.
My hypothesis here is that the User is Logged In on the Server side, but not on the Client side and the browser does not recognise that the User is Logged In . The triggers therefore do not happen.
Could anyone confirm this?
Problem 3: Test V2 Slack Sign Up API
Acting on the second hypothesis from Problem 2, I tried implementing the Log In on the page’s Workflows instead, while keeping the Sign Up in the Backend to continue enabling validation. This approach isn’t very feasible due to the asynchronous nature of Backend Workflows, causing the Log In event to be triggered before the Sign Up is complete. I’ve tried to address this below:
- Trying to get some form of a response from the Backend Workflow, and using that to limit ( Only when Result of Step 4 is “200” ) the Log In event from triggering. This however does not seem to work as I’m unable to get the Backend Workflow to communicate with the Client . Is there any way for the Backend Workflow to communicate with the Client on when it’s completed running or whether it’s successful?
Thanks for reading this far! Any other ways experienced Bubblers can think of to solve my use case?