Support » Plugin: API Bearer Auth » API whitelist problem

  • Resolved diashima


    Hello! I successfully added endpoint ‘/wp-json/wp/v2/posts’ to whitelist, but I still can’t open particular post.
    My question is – what endpoint I must write to make available without authorization every post? Something like: ‘/wp-json/wp/v2/posts/{ID}’
    Putting * in place of {ID} is not working.

    add_filter('api_bearer_auth_unauthenticated_urls', 'api_bearer_auth_unauthenticated_urls_filter', 10, 2);
    function api_bearer_auth_unauthenticated_urls_filter($custom_urls, $request_method) {
      switch ($request_method) {
        case 'POST':
          $custom_urls[] = '/wp-json/wp/v2/users/register';
        case 'GET':
          $custom_urls[] = '/wp-json/wp/v2/posts';
      return $custom_urls;
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter diashima


    And how i can put two endpoints for GET to whitelist?

    Plugin Author michielve



    You have to use regular expressions, so for posts it will be:


    To add 2 or more endpoints, just add them, for example:

    $custom_urls[] = ‘/wp-json/wp/v2/posts’;
    $custom_urls[] = ‘/wp-json/wp/v2/pages’;
    $custom_urls[] = ‘/wp-json/wp/v2/posts/[\d]+’;

    Best wishes,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘API whitelist problem’ is closed to new replies.