⚠️ This lesson is retired and might contain outdated information.

Configuring API End User Permissions in Strapi

Daniel Phiri
InstructorDaniel Phiri
Share this video with your friends

Social Share Links

Send Tweet
Published 2 years ago
Updated 11 months ago

With our mock data setup, let's make some API calls to our Strapi project. We will need to set up our permissions so that only people we want to make requests can.

To make my API calls, I use the Thunder Client in VSCode. We can currently make calls to our API without any authentication.

In our Strapi project, we can create API Tokens to make REST API calls for our data.

Instructor: [0:00] We want to make requests to our Strapi API to get the posts entries that we just put into Strapi. To do that, we'll go to our settings. We'll click roles under user and permissions plugin, and select the public role. [0:17] We select our post collection type and give ourselves access to findOne operations, which may get request to our API. Find operations and then we'll save.

[0:31] We'll open VS Code and click our Thunder Client extension. Click new requests. We'll get rid of that, and now, we'll make a get request to http://localhost:1337/api/posts.

[0:55] We get exactly what you need, our entries that we put into the Strapi content manager. We'll go back to our Strapi application and update our settings. We'll revoke our access to find and findOne, and save.

[1:15] When we try and make a new query in Thunder Client, we get a 403 Forbidden error because we revoked access to the API. In our Strapi admin, we also have the ability to use API tokens.

[1:32] We'll create a new API token and call this, "Get posts data," and make this full access. We'll save our data and copy our token. We'll go back into our Thunder Client to make an authenticated request with our new token.

[1:53] We'll go to auth and select Bearer and paste in our Bearer token. When we make our request, we get back the data that we want. That is how you set up permissions to make queries to your Strapi API.

egghead
egghead
~ an hour ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today