"stat": "ok", "result": 1 when credentials are correct
stat="fail", err = 999, message="Invalid username/password" when credentials are wrong
"stat": "ok", "result": 1 when the API keys are correct
stat="fail", err = 999, message="Invalid username/password" when API keys are wrong. It should instead return something like stat="fail", err = 998, message="Invalid API keys" so that third party apps can differentiate invalid credentials from invalid API keys.
Could you please fix this in version 16 RC2?
NB: The error code 998 is available.
The API method `pwg.session.login` returns:
- `"stat": "ok", "result": 1` when credentials are correct
- `stat="fail", err = 999, message="Invalid username/password"` when credentials are wrong
- `"stat": "ok", "result": 1` when the API keys are correct
- `stat="fail", err = 999, message="Invalid username/password"` when API keys are wrong. It should instead return something like `stat="fail", err = 998, message="Invalid API keys"` so that third party apps can differentiate invalid credentials from invalid API keys.
Could you please fix this in version 16 RC2?
NB: The error code 998 is available.
<!-- github-sync-id:3578099039 -->
We're discussing with @LintyDev about your request. This is not what we had understood during the last meeting.
When 2FA is enabled, when calling pwg.session.login:
if the username provided matches an API Key ID pattern "pkid-...", we keep doing as usual
if the username is not a "pkid-..." then Piwigo responds with a new error code and a translated error "2FA is enabled. Use an API Key." without redirecting.
I don't see the added value to tell the user "invalid API key" when using this "trick" to use an API key ID/secret as username/password in pwg.session.login.
Another different case is when you use the API key in the "authorization" header, then yes you need a specific error code. But that's another story compared to the trick of using an API Key on pwg.session.login.
We're discussing with @LintyDev about your request. This is not what we had understood during the last meeting.
When 2FA is enabled, when calling `pwg.session.login`:
- if the username provided matches an API Key ID pattern "pkid-...", we keep doing as usual
- if the username is not a "pkid-..." then Piwigo responds with a new error code and a translated error "2FA is enabled. Use an API Key." without redirecting.
I don't see the added value to tell the user "invalid API key" when using this "trick" to use an API key ID/secret as username/password in `pwg.session.login`.
Another different case is when you use the API key in the "authorization" header, then yes you need a specific error code. But that's another story compared to the trick of using an API Key on `pwg.session.login`.
<!-- github-comment-id:3481165379 -->
Yes, we did not discuss this in the meeting. But I then realised that we had no mechanism for informing a third party app that 2FA is enabled.
So I came with this idea which is compatible with current third party apps, which better informs the user and which is a way to inform the app that 2FA is enabled and that the app should proceed further i.e. ask for the 2FA method, etc.
Yes, we did not discuss this in the meeting. But I then realised that we had no mechanism for informing a third party app that 2FA is enabled.
So I came with this idea which is compatible with current third party apps, which better informs the user and which is a way to inform the app that 2FA is enabled and that the app should proceed further i.e. ask for the 2FA method, etc.
<!-- github-comment-id:3481637287 -->
This is already the case; we have an appropriate response when the user logs in with their credentials via the API but 2FA is enabled. https://github.com/Piwigo/piwigo-two_factor/blob/21a7ec047eed71bb1f8a5b233842ac6c2caab0a9/includes/events.inc.php#L70
<!-- github-comment-id:3490083064 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
The API method
pwg.session.loginreturns:"stat": "ok", "result": 1when credentials are correctstat="fail", err = 999, message="Invalid username/password"when credentials are wrong"stat": "ok", "result": 1when the API keys are correctstat="fail", err = 999, message="Invalid username/password"when API keys are wrong. It should instead return something likestat="fail", err = 998, message="Invalid API keys"so that third party apps can differentiate invalid credentials from invalid API keys.Could you please fix this in version 16 RC2?
NB: The error code 998 is available.
We're discussing with @LintyDev about your request. This is not what we had understood during the last meeting.
When 2FA is enabled, when calling
pwg.session.login:I don't see the added value to tell the user "invalid API key" when using this "trick" to use an API key ID/secret as username/password in
pwg.session.login.Another different case is when you use the API key in the "authorization" header, then yes you need a specific error code. But that's another story compared to the trick of using an API Key on
pwg.session.login.Yes, we did not discuss this in the meeting. But I then realised that we had no mechanism for informing a third party app that 2FA is enabled.
So I came with this idea which is compatible with current third party apps, which better informs the user and which is a way to inform the app that 2FA is enabled and that the app should proceed further i.e. ask for the 2FA method, etc.
This is already the case; we have an appropriate response when the user logs in with their credentials via the API but 2FA is enabled. https://github.com/Piwigo/piwigo-two_factor/blob/21a7ec047eed71bb1f8a5b233842ac6c2caab0a9/includes/events.inc.php#L70