When making a request to the Piwigo API using an api_key, if the called method requires a pwg_token, the client must still send a pwg_token parameter in the request. In practice, this means sending something like:
$data['pwg_token']='fake one';
This behavior is not consistent with the API documentation and is not a good practice, since the value of the token does not actually matter in this context.
Since api_key authentication is stateless and not subject to browser CSRF protections, requiring a client to send a dummy pwg_token parameter is unnecessary.
For this reason, we decided to always set the pwg_token automatically when the API is called with a valid api_key. This removes the need for clients to send a fake token.
Currently in the code we have the following logic:
```php
if (isset($_POST['pwg_token']))
{
$_POST['pwg_token'] = get_pwg_token();
}
if (isset($_GET['pwg_token']))
{
$_GET['pwg_token'] = get_pwg_token();
}
```
When making a request to the Piwigo API using an `api_key`, if the called method requires a `pwg_token`, the client must still send a `pwg_token` parameter in the request. In practice, this means sending something like:
```php
$data['pwg_token'] = 'fake one';
```
This behavior is not consistent with the API documentation and is not a good practice, since the value of the token does not actually matter in this context.
Since `api_key` authentication is stateless and not subject to browser CSRF protections, requiring a client to send a dummy `pwg_token` parameter is unnecessary.
For this reason, we decided to always set the `pwg_token` automatically when the API is called with a valid `api_key`. This removes the need for clients to send a fake token.
<!-- github-sync-id:4072390563 -->
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.
Currently in the code we have the following logic:
When making a request to the Piwigo API using an
api_key, if the called method requires apwg_token, the client must still send apwg_tokenparameter in the request. In practice, this means sending something like:This behavior is not consistent with the API documentation and is not a good practice, since the value of the token does not actually matter in this context.
Since
api_keyauthentication is stateless and not subject to browser CSRF protections, requiring a client to send a dummypwg_tokenparameter is unnecessary.For this reason, we decided to always set the
pwg_tokenautomatically when the API is called with a validapi_key. This removes the need for clients to send a fake token.