Viewing 4 replies - 1 through 4 (of 4 total)
  • Same here, I have followed the steps and I do retrieve a token:

    {
    “token”: “eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvcG9ycGhhLmNvbSIsImlhdCI6MTYwMjYzNzk4NCwibmJmIjoxNjAyNjM3OTg0LCJleHAiOjE2MDMyNDI3ODQsImRhdGEiOnsidXNlciI6eyJpZCI6IjMifX19.yNErmjwVxBc2vnFyUHaDiZH_X_YIozcJTgPCJZqMnjQ”,
    “user_email”: “[email protected]”,
    “user_nicename”: “bats”,
    “user_display_name”: “bats”,
    “roles”: [
    “administrator”
    ],
    “store_name”: “bazaldua”,
    “store_id”: 3
    }

    Then I try to do a simple GET of https://site.com/wp-json/wcfmmp/v1/products and it returns 401.

    Plugin Author WC Lovers

    (@wclovers)

    Hello,
    To use the authentication basic or JWT auth you must use one of the plugins recommended by WP for the purpose. https://developer.ww.wp.xz.cn/rest-api/using-the-rest-api/authentication/#authentication-plugins

    To be more specific Fore Basic auth use the plugin: https://github.com/WP-API/Basic-Auth
    And for JWT auth use the plugin: https://ww.wp.xz.cn/plugins/jwt-authentication-for-wp-rest-api/

    WordPress by default doesn’t support authentication via rest API. You must use the plugins recommended by WP. For more details find the guide to do the authentication in the plugins details page. Our apps are working fine with JWT auth plugin so please follow the guide mentioned in the plugin.

    @edbatbaz81 after getting the token please send the token in the request headers while making GET, POST, PUT requests. The authentication method should be Bearer Token in the header while sending the token.

    Thanks for your response, I do use the one that you recommended in the pages mentioned, it just simply doesn’t work.
    I opened a ticket with my hosting provider and they tell me that everything is ok. I think a wider documentation or better examples could give a hand in to this.

    Thread Starter sitemba

    (@sitemba)

    @edbatbaz81 Mine didn’t work either even after adding the bearer token to the request. On further inspection, I found that the problem was in my .htaccess file. Try changing yours to this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    RewriteCond %{HTTP:Authorization} ^(.*)
    RewriteRule ^(.*) – [E=HTTP_AUTHORIZATION:%1]
    </IfModule>
    SetEnvIf Authorization “(.*)” HTTP_AUTHORIZATION=$1
    # END WordPress

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Cannot Authenticate’ is closed to new replies.