WP-API / WP-API/OAuth2

Add permission_callback to Route Registration

Open Beginner friendly
#69 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
175
Forks
45
Avg merge
17h 8m
Merged PRs (30d)
4

Description

As of WordPress 5.5, if a permission_callback is not provided, the REST API will issue a _doing_it_wrong notice.

This is a function that checks if the user can perform the action (reading, updating, etc) before the real callback is called. This allows the API to tell the client what actions they can perform on a given URL without needing to attempt the request first.

For REST API routes that are intended to be public, use __return_true as the permission callback

There are two places to add the permissions callback:
The /access_token route.
The /authorize route.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting inc/endpoints/class-token.php for the access_token route and inc/endpoints/namespace.php for the authorize route. Check how each route is registered and verify the completed registrations provide permission callbacks without the WordPress 5.5 doing_it_wrong notice.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
api, authentication
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.