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 text on README doesn't explain authencation is needed #2521

Open
tejohnso opened this issue Feb 5, 2023 · 7 comments
Open

API text on README doesn't explain authencation is needed #2521

tejohnso opened this issue Feb 5, 2023 · 7 comments

Comments

@tejohnso
Copy link

tejohnso commented Feb 5, 2023

Versions

  • Pi-hole: 5.15.3
  • AdminLTE: 5.18.3
  • FTL: 5.20.1

Platform

  • OS and version: Raspbian 10 buster
  • Platform: Raspberry Pi

Expected behavior

The api should work as documented in README.

With either no parameters or /admin/api.php?summary it returns the following JSON ...

Actual behavior / bug

Calling /admin/api.php as indicated in the readme page returns []

Steps to reproduce

Steps to reproduce the behavior:

curl http://localhost/admin/api.php

Additional context

I noticed there's an additional post about upcoming changes with additional authorization requirements, but there is no indication from the response that authorization is required. And when I include authorization (?summary&auth=[token]) I get the same [] result.

Also the additional info link from the readme leads to a page that reiterates no authorization is necessary for "summary (default if no parameters are given)".

The following api call works:

curl "http://localhost/admin/api.php?type&version"
{"type":"FTL","version":3}
@rdwebdesign
Copy link
Member

You need to add &token=<your_pihole_api_token> to every URL.

This behavior was changed last year.

It was announced in November (as you already noticed) and December Release Notes (under "Pi-hole Web changes").

@rdwebdesign
Copy link
Member

rdwebdesign commented Feb 5, 2023

Just to make it clear:
This is a documentation error.

The behavior you saw is the correct one.
The issue is on the README text not on the code.

@rdwebdesign rdwebdesign changed the title api returning empty json API text on README doesn't explain authencation is needed Feb 5, 2023
@tejohnso
Copy link
Author

tejohnso commented Feb 5, 2023

Agree there's a documentation problem.

But I think there's a code error as well. If auth is required, the response shouldn't be 200 OK with an empty json array in the body. That's misleading.

Also, from the announcement, the parameter to include is auth not token as you indicated. But regardless of which of those I use, I still get the empty json array as a response.

@rdwebdesign
Copy link
Member

Yeah... sorry. auth is the correct parameter.

But regardless of which of those I use, I still get the empty json array as a response.

Which URL are you using exactly?

@tejohnso
Copy link
Author

tejohnso commented Feb 5, 2023

Sorry I had a problem on my end with cURL. I'm able to get it working now.

So I'd say the only issue now is the documentation and the false 200 response.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2023

This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.

@github-actions github-actions bot added the stale label Mar 8, 2023
@yubiuser yubiuser added Bug and removed stale labels Mar 8, 2023
@domdfcoding
Copy link

I second the request for a better error code than 200 when authentication is required but no token supplied. It wasn't apparent why I was getting an empty response with a 200 code. Receiving 401 (or 403 if the token was wrong) would have made it clear what was wrong.

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

No branches or pull requests

4 participants