]> git.mxchange.org Git - friendica.git/commitdiff
API: Tests with various clients, small fixes
authorMichael <heluecht@pirati.ca>
Thu, 10 Jun 2021 06:26:34 +0000 (06:26 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 10 Jun 2021 06:26:34 +0000 (06:26 +0000)
doc/API-Mastodon.md
src/Module/OAuth/Authorize.php
src/Object/Api/Mastodon/Application.php

index 34ce884fadcabcfb43a94aa05efc550d979e713b..552bd2f68d6cb37321bbbe530a919d1e8f615426 100644 (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
 
index 3fcee92469db9ba65bf722185b36eb72fa3ed50a..105ea2c36b14ab6c335f2356996ee5749de2021b 100644 (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);
        }
 }
index 1f31ca8ec7cd46f25b65782601fab4cd9a569593..c8b286d5fa04e4a6b335953dbf3bd37169371179 100644 (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;