<span class="resolved" aria-label="Resolved" title="Topic is resolved."></span>API error: 403 rest_forbidden

[ad_1]

Replies: 4

Hello!

I get an error when trying to send a GET request to endpoint http://mysite/wp-json/filebird/public/v1/folders.

I’m making a react app. I use wpapi for sending requests and JWT plugin for generating Bearer tokens.

My code:

export async function getMedia() {

  try {

    const jwt = await wp.url(reactPress.api.rest_url + 'jwt-auth/v1/token')

      .create({

        username: 'admin',

        password: appPassword,

      })

      .then((result) => {

        return result;

      });

    const result = await wp.url(reactPress.api.rest_url + 'filebird/public/v1/folders')
    .setHeaders('Authorization', 'Bearer ' + jwt.token);

    return result;

  } catch (error) {

    console.error(error);

    return [];

  }

}

How can I fix my problem?

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer