Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access Denied on everything except for /token & /token/validate #91

Open
rexwreyes opened this issue Feb 7, 2023 · 4 comments
Open

Comments

@rexwreyes
Copy link

I can get the token and validate it with no issues. Trying to hit any other endpoint however I get Access Denied. I thought i saw some method of whitelisting the routes you want to use but can't seem to figure out how to do this.

@dominic-ks
Copy link
Collaborator

Hello @rexwreyes, I assume you've read the "Whitelisting Endpoints" section here? If it's not working for you, please do paste some code that you're using, and I'll be happy to check it over.

@rexwreyes
Copy link
Author

rexwreyes commented Feb 7, 2023

I have this in my functions.php

add_filter( 'jwt_auth_whitelist', function ( $endpoints ) { $your_endpoints = array( '/wp-json/mesilinka/v1/upload', ); return array_unique( array_merge( $endpoints, $your_endpoints ) ); } );

Is this right? Should it be somewhere else?

@rexwreyes
Copy link
Author

oh here is the rest init

add_action('rest_api_init', function () { register_rest_route('mesilinka/v1', '/upload', array( 'methods' => 'POST', 'callback' => 's3toPost', 'permission_callback' => function () { return true; }, 'args' => array( 'id' => array( 'validate_callback' => function ($param, $request, $key) { return is_numeric($param); } ), ), )); });

@dominic-ks
Copy link
Collaborator

OK, that looks like it should work, though I haven't tested it. To ask an obvious question, I assume you are sending the JWT with your requests once you've got one...? What error are you getting exactly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants