migueesc123 / WooCommerceConnector

A Power BI Custom Connector for WooCommerce
MIT License
30 stars 12 forks source link

Issue connecting #2

Closed fosselius closed 7 years ago

fosselius commented 7 years ago

Hi, Trying to use this connector with Power BI (june 2017) and WooCommerce version 3.1.2 (WP 4.8.1) but after I entered the consumer key/secret as user/pass I get the message "The field "X-WP-TotalPages" of the record wasn't found. This only happens when I try to connect to our own installation, when I test your site everything works fine.

Any hints on where I should look for errors?

migueesc123 commented 7 years ago

I'd recommend that you download fiddler and check how the response that you're getting looks like. You should have the X-WP-TotalPages in your response header and usually you only get that error if your authentication is incorrect. Also, is REALLY important to use https and not http

fosselius commented 7 years ago

I will check and see! It should be sufficient with read rights on the API key shouldnt it?

Have you figured out a way to show the product lines on the order?

migueesc123 commented 7 years ago

I'm guessing that its the url that it wasn't typed as https. Once you change that to be https, then it should work perfectly. The read rights is what I have set up and they work perfectly.

In regards to the product lines, they actually show up in the connector as well inside the orders. You just have to expand that field image it's the one that reads "line_items"

fosselius commented 7 years ago

I am using https when connecting, still get the error though. Will download fiddler and see

fosselius commented 7 years ago

HTTP/1.1 401 Unauthorized Very strange! Generated a new key and tried that one instead - Still the same problem

migueesc123 commented 7 years ago

Would you mind sharing the url of your WooCommerce store?

fosselius commented 7 years ago

https://www.applearmband.se

migueesc123 commented 7 years ago

I wish that I could test it! your site does appear to be using wordpress and has woocommerce installed alongside a custom plug in for a payment gateway (mondido).

I wish that I could be of more help, but at this point it requires dedicated attention to see what's going on with your site in detail and why your authentication is failing.

migueesc123 commented 7 years ago

My advice would be to test out the authentication on any other tool and see if it works there. If it's still not working, then is not due to the connector, but rather something on the actual site. Here's the documentation that I used from the woocommerce plug in: http://woocommerce.github.io/woocommerce-rest-api-docs/#authentication

fosselius commented 7 years ago

Thank you so far! Will try out the authentication. I am using app on my phone that is using the api so I think it should be working. Will continue the testing.

fosselius commented 6 years ago

Using this: https://www.applearmband.se/wp-json/wc/v2/orders?consumer_key=myCK&consumer_secret=myCS works fine and give me the result back as a JSON

migueesc123 commented 6 years ago

hey!

While it is certainly possible to add those parts to the request url, from a security standpoint, I wouldn't recommend sending your credentials as plain text like that. Currently, Power Query encrypts your credentials and adds it as part of the security part of the request like this: image

Taking that into consideration, if your request works, then this custom connector should work as well. If it's not working then it would require some digging to see what's going on at your WooCommerce level that is denying the access.

You can give it a try by just doing this request with the regular "From Web" Connector: https://www.applearmband.se/wp-json/wc/v2/orders

in Power Query and simply choosing the Username/Password authentication and input your ck and cs. In essence, that is exactly what the Custom Connector is doing.

fosselius commented 6 years ago

Thank you! It seems like our site cant handle the call when the details are encrypted. Tried according to your suggestion above and then it doesnt work. Since you seem to be a Woo/WP ninja, can you give me a hint on where to look inside WP to find out what is happening?

migueesc123 commented 6 years ago

Hey! Thanks for the compliment, but I'm truly not anywhere near a Woo/WP ninja. I'm just a regular Power Query player

In the specific case of your server, this excerpt from the WooCommerce API documentation might be relevant: image There's a high chance that there might be an issue at the server level which is causing the encrypted credentials over basic authentication to not be authorized somehow. This might also uncover other issues at the server, so it would be a good investment to hire a pro to take a look at your server and see if everything is ok.

I haven't hired any WooCommerce experts yet, but the actual site from Woo usually recommends going directly to their partners or posting a job on https://codeable.io/

Again, thank you so much for your feedback! In the event that more people get this same issue, I'll try to create a workaround for this custom connector to connect first using the encryption and, if that doesn't work, it'll try to use the credentials inside the query parameters - but again, this is not recommended from a security standpoint even if the connection is made through https.