The webhook URL is invalid: 'localhost' cannot be used while using NGROK - wordpress

Currently building a custom Wordpress Woocommerce theme locally with MAMP and Mollie as provider. Unfortunately I do get an error when I use Mollie in testmodus during checkout.
The error:
[2022-03-17T20:59:04+0000] Error executing API call (422: Unprocessable Entity): The webhook URL is invalid: 'localhost' cannot be used as it is unreachable from Mollie's point of view.. Documentation: https://docs.mollie.com/overview/handling-errors. Request body: {"status":422,"title":"Unprocessable Entity","detail":"The webhook URL is invalid: 'localhost' cannot be used as it is unreachable from Mollie's point of view.","field":"webhookUrl","_links":{"documentation":{"href":"https://docs.mollie.com/overview/handling-errors","type":"text/html"}}}. Field: webhookUrl
I'm already using NGROK to make the website available over the internet. I even tested if I can reach it on a different domain. So it looks like NGROK itself is working as expected. Unfortunately I still get the error from Mollie.
I use the following line to start ngrok:
ngrok http 8888 -host-header=rewrite
Am I missing something? I can remember I used ngrok with mollie before without a problem.

Related

Laragon's Quick Share with Ngrok not working as expected

So, I tried Laragons Quick Share to share my localhost website so that others can proofread it. But when accessing the site it shows the following error:
So I signed up and installed an authtoken and entered that authtoken in the myproject.yml file. But now I get this instead when entering the Ngrok URL:
Adding /myproject.com after the Ngrok URL doesn't work either. What am I doing wrong?

WooCommerce - Auto generating API keys using our Application Authentication Endpoint give 401 Invalid URL error

I'm attempting to use the REST API provided by WooCommerce to generate the Customer Secret and Customer Key values so that it could be used to invoke other WooCommerce REST APIs. I referred the documentation about generating the key values and managed to get it working using a mock endpoint in Postman used for the call_back URL in the API as mentioned in the document.
I created a POST service in my backend server and managed to setup a SSL certificate in the local environment with a domain mapped in hosts file in /etc directory. I ran the backend service and invoked the callback url through Postman and it worked. Then I used that as the call_back URL in the actual WooCommerce Auth endpoint to programatically generate the keys and save it in my DB. But I'm getting
"Access Denied" - Error: A valid URL was not provided..
When I checked the browser through devtools -> network noticed that there is a 401 Unauthorize error.
Here is the sample GET URL that is uesd for WooCommerce API key generation
http://localhost/woocommerce/wc-auth/v1/authorize?app_name=<SOME_NAME>&scope=read_write&user_id=36&return_url=http://localhost/woocommerce/&callback_url=https://foo.bar.dev:44329/api/services/app/woo_commerce_auth/6/callback
callback_url = https://foo.bar.dev:44329/api/services/app/woo_commerce_auth/6/callback
When the callback_url is a mock url generated using Postman it works fine
callback_url = https://513ca6ab-db16-4635-8d0b-9159e3b1e187.mock.pstmn.io/api/services/app/woo_commerce_auth/6/callback
Any clue why this happens, I could not find a way to troubleshoot this issue. Appreciate the help.
Hi posting this for future reference, and hope it would help others who face this problem as well.
Things to keep in mind when setting the callback_url,
Non HTTPS URL endpoint are not allowed.
URL should not be a localhost url (e.g localhost/callback would give an invalid URL error)
URL should not contain port number (e.g localhost:4320/callback or foo.bar.dev:4892/callback are invalid)
Callback URL should be a POST url
If an error such as Error: An error occurred in the request and at the time were unable to send the consumer data. is given after checking all the above check the backend service code related to the callback_url (I had a 500 server error which triggered this, it was not a WooCommerce issue)
Also a tool such as ngrok would be really helpful to setup an HTTPS endpoint in your local environment to test this.

Postman keycloack issuedFor

I'm trying to make a request from postman to keycloack for authorization test and still getting this error:
{
"error": "invalid_request",
"error_description": "You must provide the issuedFor"
}
PostMan request parameters:
Postman bearer token header:
I know you've already picked an answer, but for the ones landing here from a web search on the Keycloak's issuedFor problem.
The root cause of the error message shown is the typo in the parameter name "audience" (not "audiance)". That nowadays would make Keycloak to fail fetching the client ID at https://github.com/keycloak/keycloak/blob/3631618b245fa768bff7009b9e87d01dd4387fe3/services/src/main/java/org/keycloak/authorization/authorization/AuthorizationTokenService.java#L330. Just fix the spelling and you should be fine.
For the record, the "audience" parameter is required in the requests to evaluate permissions as stated in the Keycloak's documentation for the Authorization Services: https://www.keycloak.org/docs/latest/authorization_services/index.html#_service_obtaining_permissions.
Ook i found the problem and resolved it. Keycloak does not give access to some type of requests when going out of the network. You must put it in https. When on your local machine, it does work but as soon as you go out of localhost to the network to reach keycloak, you must pass to https.
So what i did is, in my request url, i changed the link to keycloak from http to https and hence changed the port from 8080 to 8443 (the port for https serving). Hope it would help someone. Special thanks to #RossPresser :)

Rest api returns error 403 while calling from Wordpress but works in postman

I have one server on which Apache and Tomcat both are installed to run my Wordpress and Java application respectively. Both are on same ip address and using same domain https://www.example.com only port number is different.
Wordpress is running on default port while Tomcat is runing on 8443.
A rest api on Tomcat https://www.example.com:8443/myApi.html is working fine from postman, but when calling from wordpress using ajax, it returns error 403 forbidden response.
I am stuck on searching its solution but failed.
Please help me out to solve this issue.
Thanks
You cannot use a different port, even when using the same domain. This breaks the Same origin policy.You can however use JSONP if you have access to both the daemon and the requesting site. If data needs to be returned, then the daemon needs to support a callback query parameter and return it properly formatted.
please see 1) https://stackoverflow.com/a/2099771
https://stackoverflow.com/a/2099784

Ngrok not working correctly

I've installed ngrok in Win 10 on a VM but I don't think it's working correctly.
To start it up and I use this command below to run it
ngrok http -host-header="localhost:44368" 44368
and it looks like ngrok starts up ok, but when I put the https url given by ngrok into a browser this is what I see
Shouldn't I see something?
and in the ngrok console I see the get requests but no response times or response messages
same with the localhost:4040 page and every get request has a 0ms response time
I had the same issue running an ASP.NET Core MVC Server.
Upon lots of investigation, disabling the https url of my server seemed to work.
So essentially forcing it to only use http.
I had the problem using both http and https ngrok urls.
So for my ASP.NET core project in the launchSettings.json, ensure you only have the http option, remove the https url under your desired launch profile:
"applicationUrl": "http://localhost:5001;"
If it is still not works for you after #MikeDub's fix, please try this.
Go to properties of your startup project (api project) and untick,
Enable SSL
in Debug section.
As MikeDub mentioned above, I also found the exact explanation on Twilio documentation here:
https://www.twilio.com/docs/sms/quickstart/csharp-dotnet-core#allow-twilio-to-talk-to-your-aspnet-core-application-with-ngrok
which indicates removing https App Url.

Resources