]> git.mxchange.org Git - friendica.git/commitdiff
Fix connection issues with AndStatus
authorMichael <heluecht@pirati.ca>
Thu, 13 May 2021 22:00:40 +0000 (22:00 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 13 May 2021 22:00:40 +0000 (22:00 +0000)
doc/API-Mastodon.md
src/Module/OAuth/Token.php

index 18af62be68713f1576a9ff6c19e3044f34a8b038..09cf169e2b7aba8ebf7a4f82f398f901af1fd630 100644 (file)
@@ -16,12 +16,13 @@ Supported mobile apps:
 - Tusky
 - Husky
 - twitlatte
+- AndStatus
+- Twidere
 
 Unsupported mobile apps:
 
 - [Subway Tooter](https://github.com/tateisu/SubwayTooter) Uses the wrong grant_type when requesting a token, possibly a problem in the server type detection of the app. See issue https://github.com/tateisu/SubwayTooter/issues/156
 - [Mammut](https://github.com/jamiesanson/Mammut) States that the instance doesn't exist. Most likely an issue in the vitality check of the app, see issue https://github.com/jamiesanson/Mammut/issues/19
-- [AndStatus](https://github.com/andstatus/andstatus) Doesn't provide all data at token request, see issue https://github.com/andstatus/andstatus/issues/537
 - [Fedilab](https://framagit.org/tom79/fedilab) Automatically uses the legacy API, see issue: https://framagit.org/tom79/fedilab/-/issues/520
 
 ## Entities
index c3aaac6d1e329e1cf8c80a4f64fb3ba70a665878..0a1a32b7441167770d0058437c7adf050311f965 100644 (file)
@@ -41,6 +41,15 @@ class Token extends BaseApi
                $client_id     = $_REQUEST['client_id'] ?? '';
                $client_secret = $_REQUEST['client_secret'] ?? '';
 
+               // AndStatus transmits the client data in the AUTHORIZATION header field, see https://github.com/andstatus/andstatus/issues/530
+               if (empty($client_id) && !empty($_SERVER['HTTP_AUTHORIZATION']) && (substr($_SERVER['HTTP_AUTHORIZATION'], 0, 6) == 'Basic ')) {
+                       $datapair = explode(':', base64_decode(trim(substr($_SERVER['HTTP_AUTHORIZATION'], 6))));
+                       if (count($datapair) == 2) {
+                               $client_id     = $datapair[0];
+                               $client_secret = $datapair[1];
+                       }
+               }
+
                if ($grant_type != 'authorization_code') {
                        Logger::warning('Unsupported or missing grant type', ['request' => $_REQUEST]);
                        DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Unsupported or missing grant type'));