Add a second parameter to BaseApi::getRequest to enable API tests

This commit is contained in:
Hypolite Petovan 2021-11-27 18:30:41 -05:00
parent d83ebe6031
commit 9cc675233d
40 changed files with 45 additions and 41 deletions

View file

@ -47,7 +47,7 @@ class Authorize extends BaseApi
'redirect_uri' => '', // Set a URI to redirect the user to. If this parameter is set to "urn:ietf:wg:oauth:2.0:oob" then the authorization code will be shown instead. Must match one of the redirect URIs declared during app registration.
'scope' => 'read', // List of requested OAuth scopes, separated by spaces (or by pluses, if using query parameters). Must be a subset of scopes declared during app registration. If not provided, defaults to "read".
'state' => '',
]);
], $request);
if ($request['response_type'] != 'code') {
Logger::warning('Unsupported or missing response type', ['request' => $_REQUEST]);

View file

@ -38,7 +38,7 @@ class Revoke extends BaseApi
'client_id' => '', // Client ID, obtained during app registration
'client_secret' => '', // Client secret, obtained during app registration
'token' => '', // The previously obtained token, to be invalidated
]);
], $request);
$condition = ['client_id' => $request['client_id'], 'client_secret' => $request['client_secret'], 'access_token' => $request['token']];
$token = DBA::selectFirst('application-view', ['id'], $condition);

View file

@ -43,7 +43,7 @@ class Token extends BaseApi
'scope' => 'read', // List of requested OAuth scopes, separated by spaces. Must be a subset of scopes declared during app registration. If not provided, defaults to "read".
'code' => '', // A user authorization code, obtained via /oauth/authorize
'grant_type' => '', // Set equal to "authorization_code" if code is provided in order to gain user-level access. Otherwise, set equal to "client_credentials" to obtain app-level access only.
]);
], $request);
// AndStatus transmits the client data in the AUTHORIZATION header field, see https://github.com/andstatus/andstatus/issues/530
$authorization = $_SERVER['HTTP_AUTHORIZATION'] ?? '';