How to read content of HTTP Webhook callback url in azure logic app? - azure-logic-apps

I added a webhook action in logic app to call long running API(from subscribe url). I'm returning OK response and calling callback url with the result once long running process is completed. I'm struggling to read result(content of callbackurl post call) in logic app next step. Logic app shows the subscribe url response as output. How to read content of callbackurl post call in logic app?

Related

GET request URL getting duplicated in call from frontend

I have an api and frontend I'm trying to connect.
The frontend and API are deployed on a kubernetes cluster. I'm calling a GET method to populate some data and the data is not being loaded from the api. I checked the method call from chrome and the API url is appended twice.
For example, a successful GET request to my API to load this data would be example.app.com/users and the url chrome is showing in debug for the GET request is example.app.com/example.app.com/users.
I verified the API GET method works and returns the data I need. Any idea what I might be doing wrong?
Are you passing "example.app.com/users" to the function that executes the GET API?
If you pass "/users", does the result work as you expect?

Validate Authentication on every request in React

I want to check if the backend is returning a error code `ERR_USER_NOT_AUTHORIZED' whenever any fetch request is sent, and logout the user from frontend if this occurs.
Basically I want to redirect user to login whenever the token is incorrect, expired, etc. One method is polling, I poll the server every x seconds and validate, but the time between polls is vulnerable and the user may see lots of errors.
P.S. I'm a newbie to React, I work mostly on Django, what I would prefer is something like #login_required decorator in Django.
You can handle this in two ways:
Every fetch would attach the authentication token in the fetch's header, and the backend would check if the token is valid. If not, the backend would send a 301 Redirect response to your fetch pointing to your login page
You can handle this in the frontend by wrapping all your fetch request routes in a method that, if the fetch fails with Unauthorised, would redirect the page to login
You can check the response.status on the back-end. It usually returns 401: not authorised.

Why am I receiving a 401 Unauthorized error when requesting API data from React?

To make a long story short, I'm building a server-rendered Express / React application and I'm trying to query the back-end, from the client, for some data. The basic flow looks like this:
User navigates to a client path applications/:id
The Application component is loaded
A GET request is made to the server's API from the Application component lifecycle method componentWillMount
The data from the response is added to Redux
The problem is that the response (step 4) is a 401 (Unauthorized). This is not an issue of being logged in or not. A valid session exists and if I navigate to the API route from the browser, I can see the expected response. As an added note, this application is similar to another application (in nearly ever relevant aspect), which does not have this issue.
Attempted troubleshooting steps:
Verified correct modules and versions
Verified correct API request path and configuration (using Axios and withCredentials config param)
Verified server routing and authentication
Verified PassportJS config
Verified the request session is being lost in the auth process
As it turns out, the problem was that I was making the API request from the componentWillMount React lifecycle method. In other words, since the component in question was being rendered on the server and wasn't yet complete, the API call was being made from the server side as well (the component had not yet mounted), meaning the cookie was not available for the API request. Hence the 401 Unauthorized error.
Reading the docs first would have saved me quite a bit of trouble:
componentWillMount() ...
Avoid introducing any side-effects or subscriptions in this method. For those use cases, use componentDidMount() instead.
This is the only lifecycle hook called on server rendering.

What is callbackURL in consumer key creation?

I want to consume API in mule esb from salesforce, using OAuth 2.0 so to get consumer key i'm configuring in salesforce API. I struct at callBack URL.
What does it mean? what should be the callback URL ?
Callback URL is the url that will being called on successful completion of the request validation in Salesforce.
Abani answered it well, just to explain more: Callback URL are those which you will mention while registering an oAuth App and will be redirected along with token, there you can write your business logic to get token and use it to consume data.
There is javascript version of oAuth implementation of Salesforce API, and can be used to understand the authentication flow: https://www.youtube.com/watch?v=ULWBdjJx1Ss
The video describes STEP BY STEP process required to obtain token and use it to get data.
Call back URL is the URL called when the request is completed.That means after the requested is completed where the control should go we will say in call back url.After the completion of the request, it will redirect to that url. In sales force OAuth authentication we will use the callback URL

Shopify Webhook getting called multiple times

In my shopify store I have setup an order creation webhook. The webhook points to a Cakephp action URL which receives the data from webhook as following:-
$content = file_get_contents ( "php://input" );
After that it is saving this order data to the app database as:-
$orderData =array('order'=>$data['order_number'],'details'=>$content);
$orders = new Order ();
$orders->saveall($orderData);
Now the issue is that for each single order created the webhook is getting invoked multiple times. Although it performs the necessary action in the first attempt, yet Shopify is not able to identify the call success and is getting it invoked again and again until the limit reaches. After the limit is reached the webhook is getting deleted from the store.
My question is that do we need to send any type of status or response to the webhook call after it performs the necessary action. Because it is not very clear from shopify webhook documentation. They state that webhook call success is determined from HTTP status 200. How can I check what is the status returned by a webhook call? How can I make sure that Shopify is informed of webhook success through my app code and it does not invokes further calls to the webhook?
Yes, you need to send a 200 response to Shopify within a short time 5s. Otherwise, Shopify will send a request in a short time.
The official guide suggests that you store the webhook data and process it with a queue, thread, or whatever ways you preferred. After that, you return a 200 response to Shopify immediately.
IMO, if there are many webhook requests sending to you, it's better to separate the webhook receiver from your app server. You can do it with AWS Lambda or docker swarm so that the webhook requests won't break your app server.
Source:
Time limit: enter link description here
Webhooks with AWS Lambda: enter link description here
Just to clarify for others, you have to explicitly return a 2XX HTTP code or it'll retry 19 times over 48 hours, then delete your webhook if it exceeds that.

Resources