• Resolved techoguy

    (@techoguy)


    Hi,
    I’m trying to use the WC REST API and I can’t get past authentication. No matter how many keys I make or try, I keep getting the same error:

    [{“code”:”woocommerce_api_authentication_error”,”message”:”Consumer Secret is invalid”}]

    I’m following the steps here: https://woothemes.github.io/woocommerce-rest-api-docs/#authentication
    currently I’m just trying Curl to get responses and using basic authentication with SSL. If I try to get the index page that works fine, but once I try something requires authentication, I get the error above. Is there something else I should be doing or is there something else wrong? Or this there anything else to try or look at to figure out what’s going on?

    Thanks for the support.

    WC Versions: 2.5.2
    WP Version: 4.4.2

    https://wordpress.org/plugins/woocommerce/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Can you show us the code you’re using to connect? Will be a problem there, not with the keys.

    Thread Starter techoguy

    (@techoguy)

    I’m following the authentication steps listed in the documentation.

    This is what I’ve tried:

    curl https://example.com/wc-api/v3/customers/email/myemail@email.com -u <key copied from dashboard>:<secret copied from dash board>
    
    curl https://example.com/wc-api/v3/customers/email/myemail@email.com?consumer_key=<key copied from dashboard>&consumer_secret=<secret copied from dashboard>

    that was executed all on one line. I’m just using a Mac’s console right now to execute and test this.

    I’ve tried other commands as well but get the same response. the key copied has “ck_” as a prefix and a long list of numbers and letters, the secret has a prefix “cs_” the same long list of numbers.

    adding example:

    curl https://wrightwoodsurveillance.com/wc-api/v3/customers/34 -u ck_xxxxcxxxxcxxx43fexxxexxxe73xxx0d5b10bxxx:cs_xxxxxxxxxxx57xxxx4a1xxxx296xxxxbf32xxxx

    Plugin Contributor Claudio Sanches

    (@claudiosanches)

    Have you tried to disable the Varnish for REST API endpoints?

    Thread Starter techoguy

    (@techoguy)

    I’m not sure if I know how to do that. I’m currently using DreamPress and they say they can’t disable Varnish.

    I have “purged varnish” and cleared my caching apps. But that didn’t help. With that suggestion, does it look like I’m doing it right, just something else is going on?

    Thread Starter techoguy

    (@techoguy)

    I’m using shipstation and onesaas and they update information in woocommerce so I thought they would be using the API, that is my own assumption though. But either way, figured theirs worked no problems, so I’m not sure why my efforts to access the API can’t even get me past authentication.

    Plugin Contributor Claudio Sanches

    (@claudiosanches)

    @techoguy

    I have “purged varnish” and cleared my caching apps. But that didn’t help. With that suggestion, does it look like I’m doing it right, just something else is going on?

    Impossible to confirm, if not try to disable the cache for the API…

    I’m using shipstation and onesaas and they update information in woocommerce so I thought they would be using the API, that is my own assumption though.

    Nop, these plugins do not uses the WooCommerce REST API.

    But either way, figured theirs worked no problems, so I’m not sure why my efforts to access the API can’t even get me past authentication.

    Yep, maybe you are still doing something wrong, like using wrong API Keys.

    Thread Starter techoguy

    (@techoguy)

    Yep, maybe you are still doing something wrong, like using wrong API Keys.

    Yeah, I’ve tried 3 sets of keys, and I was copying and pasting. So I’m really not sure what else to try. I can access the index page that doesn’t require authentication but nothing further.

    Also, even if Shipstation and OneSaas use their own API to access WC with no issues from Varnish or Caching, wouldn’t WC API work too?

    Can you tell me when others have this problem what the issue usually is? Is it usually something to do with varnish or caching plugins?

    I’m having the same issue. Woocommerce 2.4.13, wordpress 4.4.2

    I’ve tried curl and python. With API v1 through v3. The result is always 401 Consumer Secret is invalid

    Here is the Python code used (as by example from woocommerce-1.0.5 documentation)

    Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32
    Type “copyright”, “credits” or “license()” for more information.
    >>> from woocommerce import API
    >>> wcapi = API(
    url=”https://<hostname>&#8221;,
    consumer_key=”ck_xxx”,
    consumer_secret=”cs_xxx”
    )
    >>> r = wcapi.get(“products”)
    >>> r.status_code
    401
    >>> r.text
    ‘{“errors”:[{“code”:”woocommerce_api_authentication_error”,”message”:”Consumer Secret is invalid”}]}’

    I’m having the same problem, any solution or clue?

    Thread Starter techoguy

    (@techoguy)

    I still don’t have a solution.
    I have moved the site to a different host without caching and it still doesn’t work.
    Pretty frustrating.

    I’ve tried the next URL in my browser and it’s getting me the data.
    Just in case this could help, I’mt trying to figuring out this too…

    https://www.example.com/wc-api/v3/orders?consumer_key=123&consumer_secret=abc

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Since 2.6 is out in like 2 weeks, you should wait for the new API.

    https://woocommerce.wordpress.com/2016/04/22/new-rest-api-based-on-the-wp-rest-api-in-2-6/

    Since it will use WordPress’ REST API and auth system, WooCommerce won’t be blameable any longer :p

    Great New MIke, I hope this fix the problem!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘REST API Consumer Secret is invalid’ is closed to new replies.