v16.1 • pwg.session.getStatus returns guest when called with API keys #2154

Closed
opened 2026-10-05 01:08:04 +02:00 by adam · 2 comments
Owner

Since I have upgraded to 16.1, calling API methods with API Keys in HTTP header returns HTTP 401 Access denied (it worked well with version 16.0).

To reproduce the issue:

  • Open the Piwigo web API explorer
  • Call pwg.session.login with API keys as username and password
  • Call pwg.session.getStatus with API keys separated by ":" in the Authorization field

The returned user status is guest.

Since I have upgraded to 16.1, calling API methods with API Keys in HTTP header returns HTTP 401 Access denied (it worked well with version 16.0). To reproduce the issue: - Open the Piwigo web API explorer - Call pwg.session.login with API keys as username and password - Call pwg.session.getStatus with API keys separated by ":" in the Authorization field The returned user status is guest. <!-- github-sync-id:3703879337 -->
adam closed this issue 2026-10-05 01:08:04 +02:00
Author
Owner

Hi @EddyLB

It reminds me of https://piwigo.org/forum/viewtopic.php?pid=193631#p193631 : you need to clear your web browser case so that tools/ws.htm uses the correct header X-PIWIGO-API that replaces Authorization in version 16.1.0

Now regarding your workflow: when you call pwg.session.login you generate a server-side session and you get your cookie filled with the session id. If you call pwg.session.getStatus without providing X-PIWIGO-API header, you should get informations about the connected user in the current session.

If you provide the X-PIWIGO-API header when calling pwg.session.getStatus, Piwigo should use it instead of the session [... a few minutes later...] and it works fine, see my 2 screenshots:

Image

After I logged in as "plg2", pwg.session.getStatus correctly says username="plg2".

Image

If I provide an X-PIWIGO-API header with the apiKeyID:apiKeySecret, then pwg.session.getStatus correctly says username="plg".

@EddyLB did you change the header to X-PIWIGO-API in your iOS app?

Hi @EddyLB It reminds me of https://piwigo.org/forum/viewtopic.php?pid=193631#p193631 : you need to clear your web browser case so that `tools/ws.htm` uses the correct header `X-PIWIGO-API` that replaces `Authorization` in version 16.1.0 Now regarding your workflow: when you call `pwg.session.login` you generate a server-side session and you get your cookie filled with the session id. If you call `pwg.session.getStatus` without providing `X-PIWIGO-API` header, you should get informations about the connected user in the current session. If you provide the `X-PIWIGO-API` header when calling `pwg.session.getStatus`, Piwigo should use it instead of the session [... a few minutes later...] and it works fine, see my 2 screenshots: <img width="683" height="683" alt="Image" src="https://github.com/user-attachments/assets/f131a19b-4768-4186-bdd1-cd8058372e91" /> After I logged in as "plg2", `pwg.session.getStatus` correctly says `username="plg2"`. <img width="683" height="683" alt="Image" src="https://github.com/user-attachments/assets/43070133-b6b6-406d-bb73-8b0ac9986ddd" /> If I provide an `X-PIWIGO-API` header with the apiKeyID:apiKeySecret, then `pwg.session.getStatus` correctly says `username="plg"`. @EddyLB did you change the header to `X-PIWIGO-API` in your iOS app? <!-- github-comment-id:3626472887 -->
Author
Owner

Thanks @plegall for your reply.
I have cleaned the cache and it now seems to work with the web API explorer.

Yes it was changed in the iOS app. The problem is that I used X_PIWIGO_API instead of X-PIWIGO-API.

Thanks @plegall for your reply. I have cleaned the cache and it now seems to work with the web API explorer. Yes it was changed in the iOS app. The problem is that I used `X_PIWIGO_API` instead of `X-PIWIGO-API`. <!-- github-comment-id:3626581306 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#2154