Support » Plugin: WP REST API (WP API) » Authenticating with nonces

  • Hi, I am having trouble with the concept of authenticating users via WP-Rest, I haven’t found what I’m looking for in the documentation regarding this issue.

    When I add the authentication routes, the app refuses to authenticate users, and I am unable to act on the user when I am inside the callback function. It simply returns an empty array.

    Here is my header (Just trying for basic auth)

    $headers = array (
        'Authorization' => 'Basic ' . base64_encode( 'admin' . ':' . 'sdfoi4rsfd^pBx' ),

    and here is the route.

    register_rest_route( 'creator/v1', '/product', array(
            'methods' => WP_REST_Server::READABLE,
            'headers' => $headers,
            'callback'=> 'my_test_func',
            'permission_callback' => function () {
                return current_user_can('read');
        ) );

    Ultimately we are trying to authenticate users into our app via our own endpoints (which will probably just wrap around the endpoints native to the app), but I think conceptually I am missing something here. Any help or feedback at all would be appreciated.

Viewing 1 replies (of 1 total)
  • Thread Starter sistern


    The added frustration is because of this, I cannot include permission callbacks as they don’t seem to work, because it doesn’t see any user in the system.

    Should I be adding my cookies to the header?

Viewing 1 replies (of 1 total)
  • The topic ‘Authenticating with nonces’ is closed to new replies.