Jake B.
Well-known member
- Affected version
- 2.1.x
A few issues I've noticed with this process:
First:
In
This is resulting in something along the lines of:
There is currently no way to return any sort of custom response with additional details (or an actual error code (
Second, there isn't a clean way to specify the allowed scopes without creating a faux API key object with the following:
Would be much cleaner if I could simply do something along the lines of:
First:
In
\XF\Api\App::start
when $user
is returned as falsey by using the app_api_validate_request
event listener it does the following:
PHP:
return $this->getApiErrorResponse(\XF::phrase($error), $code);
This is resulting in something along the lines of:
JSON:
{
"errors": [
{
"code": "Some error message",
"message": "Some error message",
"params": []
}
]
}
There is currently no way to return any sort of custom response with additional details (or an actual error code (
invalid_token
, invalid_client
, token_revoked
, etc) that can be programmatically used to determine the specific error rather than relying on just the HTTP response code - which could potentially mean several different things). Ideally there should be some way for me to pass the entire response object so it could be tailored to standards in place for things like OAuthSecond, there isn't a clean way to specify the allowed scopes without creating a faux API key object with the following:
PHP:
/** @var ApiKey $fauxApiKey */
$fauxApiKey = \XF::app()->em()->create('XF:ApiKey');
$fauxApiKey->bulkSet([
'scopes' => $allowedScopes,
]);
\XF::setApiKey($fauxApiKey);
Would be much cleaner if I could simply do something along the lines of:
PHP:
\XF::setApiScopes($allowedScopes);