Recently upgraded flarum and php, and now having some strange issues with SSO.
Existing User = Fail
127.0.0.1 - "-" - - [06/Jan/2026:00:33:11 -0500] "GET /api/users/existinguser?bySlug=1 HTTP/1.1" 200 479 "-" "Maicol07 Flarum Api Client"
127.0.0.1 - "-" - - [06/Jan/2026:00:33:24 -0500] "POST /api/token HTTP/1.1" 401 67 "-" "Maicol07 Flarum Api Client"
127.0.0.1 - "-" - - [06/Jan/2026:00:33:35 -0500] "GET /api/users HTTP/1.1" 200 10338 "-" "Maicol07 Flarum Api Client"
127.0.0.1 - "-" - - [06/Jan/2026:00:33:44 -0500] "POST /api/token HTTP/1.1" 401 67 "-" "Maicol07 Flarum Api Client"
New User = Success
127.0.0.1 - "-" - - [06/Jan/2026:00:35:05 -0500] "GET /api/users/newtestuser?bySlug=1 HTTP/1.1" 404 59 "-" "Maicol07 Flarum Api Client"
127.0.0.1 - "-" - - [06/Jan/2026:00:35:17 -0500] "POST /api/token HTTP/1.1" 401 67 "-" "Maicol07 Flarum Api Client"
127.0.0.1 - "-" - - [06/Jan/2026:00:35:25 -0500] "GET /api/users/newtestuser?bySlug=1 HTTP/1.1" 404 59 "-" "Maicol07 Flarum Api Client"
127.0.0.1 - "-" - - [06/Jan/2026:00:35:31 -0500] "POST /api/users HTTP/1.1" 201 1006 "-" "Maicol07 Flarum Api Client"
127.0.0.1 - "-" - - [06/Jan/2026:00:35:33 -0500] "POST /api/token HTTP/1.1" 200 77 "-" "Maicol07 Flarum Api Client"
After new user signs off, they cannot sign in again same as existing user. Tried disabling many extensions and keeping just a select handful.
If you have any debugging tips I'd highly appreciate it.
sh-5.2$ php flarum cache:clear
Clearing the cache...
sh-5.2$ php flarum info
Flarum core: 1.8.11
PHP version: 8.3.26
MySQL version: 12.1.2-MariaDB-ubu2404
Loaded extensions: Core, date, libxml, hash, pcre, zlib, filter, json, SPL, pcntl, random, readline, Reflection, session, standard, openssl, sockets, bcmath, bz2, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, gmp, iconv, intl, ldap, exif, mysqlnd, PDO, Phar, posix, shmop, SimpleXML, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, xml, xmlwriter, xsl, mysqli, pdo_mysql, pdo_sqlite, xmlreader, zip, Zend OPcache, xdebug
+----------------------+---------+--------+
| Flarum Extensions | | |
+----------------------+---------+--------+
| ID | Version | Commit |
+----------------------+---------+--------+
| maicol07-sso | 1.11.7 | |
| fof-formatting | 1.1.2 | |
| flarum-flags | v1.8.2 | |
| flarum-tags | v1.8.5 | |
| flarum-approval | v1.8.2 | |
| flarum-markdown | v1.8.1 | |
| flarum-mentions | v1.8.5 | |
| flarum-subscriptions | v1.8.1 | |
| flarum-nicknames | v1.8.2 | |
+----------------------+---------+--------+
$options = [
"url" => 'https://community.' . $_SERVER['HTTP_HOST'],
"root_domain" => $_SERVER['HTTP_HOST'],
"api_key" => 'flarum_api_key',
"password_token" => "randomtoken",
"remember" => true,
"verify_ssl" => false
];
$flarum = new Flarum($options);
$flarum_user = $flarum->user($_SESSION['username']);
$flarum_user->attributes->email = $_SESSION['email'];
$flarum_user->attributes->password = 'master_password';
$flarum_user->attributes->nickname = $_SESSION['nickname'];
$result = $flarum_user->login();
Edit: Debugging locally and discovered that the POST requests to /api/token for existing users had the "identification" inside the POST body set to null. It seems to be related to changes to getters and dynamic properties in the 3.3 upgrade. Calls to $this->attributes->username inside getToken return null. The username field does not appear inside dirty attributes or relationships, and the new getter only check these (old version checked attributes field too).
Downgraded to 3.2 and all working again! 🙂
maicol07/flarum-sso-php-plugin8f621a4
private function getToken(): ?string
{
$data = [
'identification' => $this->attributes->username,
'password' => $this->attributes->password,
'remember' => $this->flarum->isSessionRemembered(),
];
try {
$response = $this->flarum->api->token()->post($data)->request();
return $response->token ?? '';
} catch (ClientException $e) {
if ($e->getResponse()->getReasonPhrase() === "Unauthorized") {
return null;
}
throw $e;
}
}