Experience User Endpoint / Workflow not being hit when GET request

User tries to go to this URL via a link (sent to them in a text message when their unit has an alarm):
https://app.machinesaver.io/vibration/5d2c851e208f0008cbc111

This should hit this endpoint via a GET request (perhaps a POST request but unlikely — in any case I have it covered with a POST request to the endpoint as well:
https://app.machinesaver.io/vibration/{deviceId}


image
Note*** POST endpoint is setup exactly the same way

The response is {“error”:“Authorization Required”}

Workflow Looks like this:


If a request from a non-logged in experience user:

I’m not sure why its not redirecting to the /login page when there is no experience user logged in.
In fact when the user hits that endpoint it doesn’t even seem to hit this workflow although it is set to be handled by the workflow:

I want to pass the parameter through and hold it in the /login page while the user logs in and then redirect them to the dashboard once they are authenticated.

Hi @Leo_Bach1,

The reason you are seeing the “error: Authorization required” message is because you have selected “no static reply” in the “Unauthorized Reply Type” configuration. This will cause the workflow attached to not run, which is why you are seeing nothing in the debug panel. You could redirect to the login page as your reply type and append parameters to the template (/login?redirect=true).

Thanks!
Julia

I’m confused about where I would add the parameters (in this case a deviceId) to the request. Can you expand on that? Would this happen in the workflow of the ENDPOINT GET /vibration/{deviceId}? In that case I guess I would need to change the “no static reply” option to something else in order to run the workflow when an unauthorized user tries to access it.

Hi @Leo_Bach1,

I messed with an experience I have to find the best way to accomplish this. In my experience, I have a page that shows me device details for a selected device (/device/{deviceId}). The Endpoint is set up like so:

You’ll notice my Access Control is set to “All public users,” and my Reply Type is set to “No Static Reply.” I did this so I could control the routing myself within the workflow, and still redirect to the login page. My page looks like so:

Selecting one of the devices from my Device List Block will send me to the /devices/{deviceId} page. This is where I want to handle my routing, so if someone selects “Device A,” I either want them to see the Device Details page, or if they are not logged in, reroute them to the login page. I set up my workflow like so:

I want to check to make sure the user is logged in before I show them the page, so I have a conditional to check this:

If the user is logged in, I give them the page they expect:


If they are not logged in, I reroute them to the /login page with a query parameter deviceId for the device they selected:


This redirect also triggers my /login workflow, and the debug shows my query parameter on the payload:

05%20PM

Now I need to handle my user logging in, and I would like to return them to the page they were redirected from. To do this, I add a Conditional Node after the Authenticate Node to check if there are any query parameters. If there are no query parameters, I know my user is trying to simply login, but if there is a query parameter I know my user was redirected to the login page from /device/{deviceId}:


Home page:
Device page:

I enter my user credentials and I am logged in and redirected back to the Device Details page with the correct deviceId:

I know this walkthrough is a bit hefty, so please let me know if anything is unclear or if you have follow up questions!

There is also an example in the Kanarra application of checking if the user has access to the selected deviceId.

Thanks,
Julia

What an excellent walkthrough, Julia. Thank you for taking the time to clear this up for me. I am going to rework some stuff tonight and will update on my progress tomorrow.
Thanks!

1 Like