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

API Key on POST requests - no effect? #131

Open
cappuccinonet opened this issue Sep 10, 2021 · 4 comments
Open

API Key on POST requests - no effect? #131

cappuccinonet opened this issue Sep 10, 2021 · 4 comments

Comments

@cappuccinonet
Copy link

Not sending a/the Bearer Authorization token on Post request does not seem to block the request. Is this a bug or a feature?

@cappuccinonet cappuccinonet changed the title API token on Posts - no effect API Key on POST requests - no effect? Sep 10, 2021
@asierraserna
Copy link

asierraserna commented Sep 16, 2021

Hello! There is a configuration file in the plugins/API/name of your api folder, where you can set the permissions, specifically the line

    // Set the login resource to be public
    $this->setResourceAccess('login', 'public', 'post');

where you can set it as private to force bearer key input .
The example is public since is the one for login.

More info here

link: Techjoomla api documentation

I hope this helps!

@cappuccinonet
Copy link
Author

@asierraserna Thanks very much for the response.
This is exactly what I did in my code, following your documentation - but for some reason it seems not to block the post request.
$this->setResourceAccess('search', 'private', 'post');

@asierraserna
Copy link

Hello!
Ah that is not my documentation, I am just another developer using the awesome code from the guys of techjoomla.

This is an example I have:

image

You can see there, I got error since I am not passing an Autorisation Header.

I my code for this api plugin, it looks like this:

// Set the login resource to be public //$this->setResourceAccess('chats', 'public', 'post'); //$this->setResourceAccess('chats', 'public', 'get');

So I actually have it commented. What I mean with this is, add the line if you want to make it public, remove the line to make it private.

I believe everything is Private by default, and then you need to add the line to make it public.

Here is much better explained:

https://github.com/techjoomla/com_api/blob/e5b6f17e50d4326ff3c1608edb954c5522a9f170/docs/plugin-development.md#private-and-public-resources

I hope it helps!

@cappuccinonet
Copy link
Author

@asierraserna This is it! Just tried to uncomment this line. It seems to work. Thank you very much.
Hopefully the folks form techjoomla will provide this awesome tool for Joomla 4, too, since it's so straight forward.

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