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

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);
}
}