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

@ -11,26 +11,44 @@ Authentication is the same as described in [Using the APIs](help/api#Authenticat
## Clients
Supported apps:
### Supported apps
#### Android
- [AndStatus](http://andstatus.org)
- [B4X for Pleroma & Mastodon](https://github.com/AnywhereSoftware/B4X-Pleroma)
- [Husky](https://husky.fwgs.ru)
- [Roma](https://play.google.com/store/apps/details?id=tech.bigfig.roma)
- [Subway Tooter](https://github.com/tateisu/SubwayTooter)
- [Tusky](https://tusky.app)
- [Twidere](https://github.com/TwidereProject/)
- [twitlatte](https://github.com/moko256/twitlatte)
- [Yuito](https://github.com/accelforce/Yuito)
#### iOS
- [Amaroq](https://github.com/ReticentJohn/Amaroq/tree/master)
- [B4X for Pleroma & Mastodon](https://github.com/AnywhereSoftware/B4X-Pleroma)
- [StarPterano](https://apps.apple.com/de/app/starpterano/id1436972796) Uses an OAuth method where you have to manually copy and paste the provided code.
- [Stella](https://apps.apple.com/us/app/stella-for-mastodon-twitter/id921372048?l=ms)
Unsupported apps:
### Unsupported apps
#### Android
- [Fedilab](https://framagit.org/tom79/fedilab) Automatically uses the legacy API, see issue: https://framagit.org/tom79/fedilab/-/issues/520
- [Mammut](https://github.com/jamiesanson/Mammut) There are problems with the token request, see issue https://github.com/jamiesanson/Mammut/issues/19
#### iOS
- [Fedi](https://apps.apple.com/de/app/fedi-for-pleroma-and-mastodon/id1478806281) Authenticates, but doesn't load posts and throws several errors
- [Mast](https://github.com/Beesitech/Mast) Doesn't accept the entered instance name. Claims that it is invalid (Message is: "Not a valid instance (may be closed or dead)")
- [Pinafore](https://github.com/nolanlawson/pinafore) Returns message "Error: NetworkError when attempting to fetch resource.. Is this a valid Mastodon instance?"
- [Mastonaut](https://mastonaut.app/)
- [Roma](https://apps.apple.com/de/app/roma-for-pleroma-and-mastodon/id1445328699) Authenticates, but doesn't load content
- [Toot!](https://apps.apple.com/app/toot/id1229021451)
- [Tootle](https://apps.apple.com/de/app/tootle-for-mastodon/id1236013466) Doesn't recognize server, loads /api/v1/instance in some endless loop
#### Other
- [Halycon](https://www.halcyon.social/) Doesn't load content, creates masses of HTTP requests
- [Pinafore](https://github.com/nolanlawson/pinafore) Returns message "Error: NetworkError when attempting to fetch resource.. Is this a valid Mastodon instance?"
## Entities

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

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;