@@ -20,20 +20,21 @@ public function register_routes() {
2020 'oauth2 ' ,
2121 '/access_token ' ,
2222 [
23- 'methods ' => 'POST ' ,
24- 'callback ' => [ $ this , 'exchange_token ' ],
25- 'args ' => [
26- 'grant_type ' => [
23+ 'methods ' => 'POST ' ,
24+ 'callback ' => [ $ this , 'exchange_token ' ],
25+ 'permission_callback ' => '__return_true ' ,
26+ 'args ' => [
27+ 'grant_type ' => [
2728 'required ' => true ,
2829 'type ' => 'string ' ,
2930 'validate_callback ' => [ $ this , 'validate_grant_type ' ],
3031 ],
31- 'client_id ' => [
32+ 'client_id ' => [
3233 'required ' => false ,
3334 'type ' => 'string ' ,
3435 'validate_callback ' => 'rest_validate_request_arg ' ,
3536 ],
36- 'code ' => [
37+ 'code ' => [
3738 'required ' => false ,
3839 'type ' => 'string ' ,
3940 'validate_callback ' => 'rest_validate_request_arg ' ,
@@ -67,7 +68,7 @@ public function validate_grant_type( $type ) {
6768 * @return array|WP_Error Token data on success, or error on failure.
6869 */
6970 public function exchange_token ( WP_REST_Request $ request ) {
70- if ( $ request [ ' grant_type ' ] === ' client_credentials ' ) {
71+ if ( ' client_credentials ' === $ request [ ' grant_type ' ] ) {
7172 return $ this ->handle_client_credentials ( $ request );
7273 }
7374
@@ -206,7 +207,7 @@ private function extract_client_credentials( WP_REST_Request $request ) {
206207 $ encoded = substr ( $ auth_header , 6 );
207208 $ decoded = base64_decode ( $ encoded , true );
208209
209- if ( $ decoded === false ) {
210+ if ( false === $ decoded ) {
210211 return new WP_Error (
211212 'oauth2.endpoints.token.invalid_request ' ,
212213 __ ( 'Invalid Authorization header. ' , 'oauth2 ' ),
0 commit comments