Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm failing to connect to WC API in production server, in local env works perfectly #15404

Closed
MelvinDRM opened this issue Jun 1, 2017 · 1 comment

Comments

@MelvinDRM
Copy link

Hello WooCommerce dev community,

It's a pleasure to greet you all. I'm in need of your guidance.

I developed a Django (python) system and it has a functionalities that are supposed to connect to WooCommerce for information about my e-store in my WordPress site.

In local enviroment the connection works perfect, but when I updated my production server, it doesn't work.

I tried with the server support to find a solution but they don't see anything wrong in their end, and I have the correct file permissions. So I come to you for guidance and wisdom.

The error that gives is:

{u'code': u'woocommerce_rest_cannot_view',
u'data': {u'status': 401},
u'message': u'Sorry, you cannot list resources.'}

I'm using the python WooCommerce library in its 1.1.1 version. This is my python code for connecting to WooCommerce:

from woocommerce import API

def connectWooCommerce(): 
    wcapi = API( 
        url="https://airwaysmag.com/", 
        consumer_key="ck_KEY_HERE",         
        consumer_secret="cs_KEY_HERE",
        wp_api=True,
        version="wc/v2"
)

return wcapi

Here is the System Report:

`

WordPress Environment

Home URL: https://airwaysmag.com
Site URL: https://airwaysmag.com
WC Version: 3.0.7
Log Directory Writable: ✔
WP Version: 4.6.6
WP Multisite: –
WP Memory Limit: 1 GB
WP Debug Mode: –
WP Cron: ✔
Language: en_US

Server Environment

Server Info: Apache
PHP Version: 5.6.30
PHP Post Max Size: 1 GB
PHP Time Limit: 0
PHP Max Input Vars: 1000
cURL Version: 7.38.0
OpenSSL/1.0.1e

SUHOSIN Installed: ✔
MySQL Version: 5.6.35
Max Upload Size: 1 GB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
GZip: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔
suhosin.post.max_array_index_length: ❌ 64 - A minimum of 256 is required.
suhosin.post.max_totalname_length: ❌ 256 - A minimum of 65535 is required.
suhosin.post.max_vars: ❌ 1000 - A minimum of 1024 is required.
suhosin.request.max_array_index_length: ❌ 64 - A minimum of 256 is required.
suhosin.request.max_totalname_length: ❌ 256 - A minimum of 65535 is required.
suhosin.request.max_vars: ❌ 1000 - A minimum of 1024 is required.

Database

WC Database Version: 2.6.14
WC Database Prefix: 77aw_
woocommerce_sessions: ✔
woocommerce_api_keys: ✔
woocommerce_attribute_taxonomies: ✔
woocommerce_downloadable_product_permissions: ✔
woocommerce_order_items: ✔
woocommerce_order_itemmeta: ✔
woocommerce_tax_rates: ✔
woocommerce_tax_rate_locations: ✔
woocommerce_shipping_zones: ✔
woocommerce_shipping_zone_locations: ✔
woocommerce_shipping_zone_methods: ✔
woocommerce_payment_tokens: ✔
woocommerce_payment_tokenmeta: ✔
MaxMind GeoIP Database: ✔

Security

Secure connection (HTTPS): ✔
Hide errors from visitors: ✔

Active Plugins (57)

Custom Bulk/Quick Edit: by Axelerant – 1.6.7
Query Monitor: by John Blackbourn – 2.13.4
Ad Inserter: by Igor Funa – 2.1.8
Akismet Anti-Spam: by Automattic – 3.3.2
Black Studio TinyMCE Widget: by Black Studio – 2.3.2
Buttons X Lite: by Gautam Thapar – 0.8.5
Check Email: by Chris Taylor – 0.5.5
Contact Form 7: by Takayuki Miyoshi – 4.7
Custom Facebook Feed: by Smash Balloon – 2.4.6
Duplicate Page And Post: by Zeeshan Aslam Durrani – 1.1
Easy Twitter Feed Widget: by DesignOrbital.com – 0.6
SM Youtube Subscribe: by Mahabubur Rahman – 1.1.0
Envato WordPress Toolkit: by Envato – 1.7.3
Huge IT Forms: by Huge-IT – 1.4.9
Frontend Uploader: by Rinat Khaziev
Daniel Bachhuber – 1.1

Google Analytics for WordPress by MonsterInsights: by MonsterInsights – 6.1.11
Product Sales Report Pro for WooCommerce: by Potent Plugins – 2.0.11
Instagram Feed: by Smash Balloon – 1.4.9
WPBakery Visual Composer: by Michael M - WPBakery.com – 4.12.1
Legatus Extended: by Orange Themes – 1.0.0
Links Shortcode: by Maarten Swemmer – 1.8.2
List category posts: by Fernando Briano – 0.72
Loginizer: by Raj Kothari – 1.3.4
User Profile Picture: by Ronald Huereca – 1.4.3
Photo Gallery: by Photo Gallery Team – 1.3.43
VarkTech Pricing Deals for WooCommerce: by Vark – 1.1.7.1
Quiz And Survey Master: by Frank Corso – 5.0.3
Regenerate Thumbnails: by Alex Mills (Viper007Bond) – 2.2.6
WP REST API: by WP REST API Team – 2.0-beta15
Scalable Vector Graphics (SVG): by Sterling Hamilton – 3.3
Social Share Buttons by Supsystic: by supsystic.com – 1.8.2
Theme My Login: by Jeff Farthing – 6.4.9
Twitter: by Twitter – 2.0.1
Ultimate Social Media PLUS: by UltimatelySocial – 2.6.3
Use Any Font: by Dinesh Karki – 4.7.3
User Role Editor: by Vladimir Garagulya – 4.33
User Submitted Posts: by Jeff Starr – 20170531
WooCommerce Customizer: by SkyVerge – 2.5.0
WooCommerce Stripe Gateway: by WooCommerce – 3.1.9
WooCommerce Memberships: by SkyVerge – 1.8.5
WooCommerce PDF Invoices: by Bas Elbers – 2.9.1
WooCommerce FedEx Shipping: by Automattic – 3.4.4 – 3.4.8 is available
WooCommerce USPS Shipping: by Automattic – 4.4.2 – 4.4.6 is available
WooCommerce: by Automattic – 3.0.7
WooCommerce Helper: by WooCommerce – 1.7.2 – Network enabled
WordPress Importer: by wordpressdotorg – 0.6.3
Yoast SEO: by Team Yoast – 4.8
WP Content Copy Protection & No Right Click: by wp-buy – 1.6
Wordpress File Upload: by Nickolas Bossinas – 3.11.0
WP Maintenance Mode: by Designmodo – 2.0.9
WP Photo Sphere: by Jérémy Heleine – 3.7.1
WP-Polls: by Lester 'GaMerZ' Chan – 2.73.6
WP RSS Aggregator: by RebelCode – 4.11.1
WP Subscribe: by MyThemeShop – 1.2.1
YITH WooCommerce Advanced Reviews: by YITHEMES – 1.2.8
YITH WooCommerce Zoom Magnifier: by YITHEMES – 1.2.29
YouTube Channel: by Aleksandar Urošević – 3.0.11.1

Settings

API Enabled: ✔
Force SSL: –
Currency: USD ($)
Currency Position: left
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 2
Taxonomies: Product Types: external (external)
grouped (grouped)
simple (simple)
variable (variable)

Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)

WC Pages

Shop base: ❌ Page not set
Cart: #41575 - /cart/
Checkout: #41576 - /checkout-page/
My account: ❌ Page not set

Theme

Name: Legatus Premium Child Theme
Version: 2.0.0
Author URL: http://www.orange-themes.com/
Child Theme: ✔
Parent Theme Name: Legatus Theme
Parent Theme Version: 2.1.7
Parent Theme Author URL: http://www.orange-themes.com/
WooCommerce Support: ✔

Templates

Archive Template: Your theme has a woocommerce.php file
you will not be able to override the woocommerce/archive-product.php custom template since woocommerce.php has priority over archive-product.php. This is intended to prevent display issues.

Overrides: –
`
I read in the docs that 401 is wrong credentials but I generated the API key fresh and placed it correctly. Is there anything that I could be missing? If you need more information, please let me know.

Thanks in advance.

Melvin

@mikejolley
Copy link
Member

I reckon it's the server's support for certain types of request. Can you try https://github.com/woocommerce/woocommerce/wiki/Getting-started-with-the-REST-API#server-does-not-support-postdeleteput

I'd also suggest testing in a rest api client like in that doc ^ verses using a library to start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants