API: Tests with various clients, small fixes

This commit is contained in:
Michael
2021-06-10 06:26:34 +00:00
parent fa2c8cad9d
commit d917ed58a8
3 changed files with 41 additions and 6 deletions
+18 -1
View File
@@ -23,6 +23,7 @@ namespace Friendica\Module\OAuth;
use Friendica\Core\Logger;
use Friendica\DI;
use Friendica\Model\Post\Content;
use Friendica\Module\BaseApi;
use Friendica\Security\OAuth;
@@ -88,6 +89,22 @@ class Authorize extends BaseApi
DI::mstdnError()->UnprocessableEntity();
}
DI::app()->redirect($application['redirect_uri'] . (strpos($application['redirect_uri'], '?') ? '&' : '?') . http_build_query(['code' => $token['code'], 'state' => $request['state']]));
if ($application['redirect_uri'] != 'urn:ietf:wg:oauth:2.0:oob') {
DI::app()->redirect($application['redirect_uri'] . (strpos($application['redirect_uri'], '?') ? '&' : '?') . http_build_query(['code' => $token['code'], 'state' => $request['state']]));
}
DI::session()->set('oauth_token_code', $token['code']);
}
public static function content(array $parameters = [])
{
$code = DI::session()->get('oauth_token_code');
DI::session()->remove('oauth_token_code');
if (empty($code)) {
return '';
}
return DI::l10n()->t('Please copy the following authentication code into your application and close this window: %s', $code);
}
}
+2 -2
View File
@@ -34,7 +34,7 @@ class Application extends BaseDataTransferObject
protected $client_id;
/** @var string */
protected $client_secret;
/** @var int */
/** @var string */
protected $id;
/** @var string */
protected $name;
@@ -53,7 +53,7 @@ class Application extends BaseDataTransferObject
{
$this->client_id = $client_id;
$this->client_secret = $client_secret;
$this->id = $id;
$this->id = (string)$id;
$this->name = $name;
$this->redirect_uri = $redirect_uri;
$this->website = $website;