MacOS client session expires (Error while creating session for user access token)

When trying to log in with the Mattermost MacOS desktop client, the session instantly expires.

Steps to reproduce
MacOS desktop client Version 5.3.1 commit: 195424a
Self-hosted server Version 7.9.1 (note this server has been running for a long time, upgraded from time to time, definitely a chance there’s legacy stuff in there)

As soon as I log in, I briefly see the channels appear. Moments later, it kicks you back to the login screen.

Observed behavior
Previously, I used Version 5.0.3 rc1 of the desktop client, this worked fine. “Clear cache & reload” in the client has no effect. Logging in through a webbrowser works fine still.

The server provides the following, I’ve manually removed the token just in case.

mattermost: {"timestamp":"2023-04-12 09:07:46.368 Z","level":"warn","msg":"Error while creating session for user access token","caller":"app/session.go:90","error":"createSessionForUserAccessToken: Invalid or missing token., resource: UserAccessToken id: token=removed"}

The developer tools console just provides a bunch of 401 messages, presumably because the session fails on the server side.

VM673:334 Preload initializedVM673:334 Preload initialized
products.ts:63 Feature flag for product boards not enabled. Not loading it.
index.js:151 Loading plugin focalboard, version 7.9.2
index.js:151 Loading plugin com.mattermost.calls, version 0.14.0
index.js:151 Loading plugin com.mattermost.plugin-channel-export, version 1.0.0
index.js:151 Loading plugin jira, version 3.2.2
index.js:151 Loading plugin playbooks, version 1.36.0
index.js:137 Loaded plugin com.mattermost.plugin-channel-export, version 1.0.0
index.js:137 Loaded plugin jira, version 3.2.2
index.js:137 Loaded plugin com.mattermost.calls, version 0.14.0
focalboard_8d74d3377207966d_bundle.js:2 [1681289884.77] OctoClient baseURL: https://removed/plugins/focalboard
index.js:137 Loaded plugin focalboard, version 7.9.2
index.js:137 Loaded plugin playbooks, version 1.36.0
client.ts:739          GET https://removed/plugins/playbooks/api/v0/settings 401 (Unauthorized)
cd @ client.ts:739
id @ client.ts:715
Gu @ client.ts:529
(anonymous) @ index.tsx:316
initialize @ index.tsx:318
(anonymous) @ index.js:172
i.onload @ index.js:136
load (async)
(anonymous) @ index.js:157
S @ index.js:118
(anonymous) @ index.js:83
v @ index.js:82
await in v (async)
(anonymous) @ root.tsx:297
(anonymous) @ root.tsx:425
await in (anonymous) (async)
componentDidMount @ root.tsx:431
hu @ react-dom.production.min.js:219
zi @ react-dom.production.min.js:259
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Ti @ react-dom.production.min.js:252
gi @ react-dom.production.min.js:243
(anonymous) @ react-dom.production.min.js:123
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Kl @ react-dom.production.min.js:123
F @ scheduler.production.min.js:16
w.port1.onmessage @ scheduler.production.min.js:12
client4.js:1757          GET https://removed/api/v4/teams?page=0&per_page=200&include_total_count=false&exclude_policy_constrained=false 401 (Unauthorized)

I’m sort of baffled as to why the desktop client and a regular browser session behave differently, even though it still feels like a server side problem. So any help is much appreciated.

Hi @Martijn and welcome to the Mattermost forums!

There’s a new behaviour which has been introduced with 5.1 or 5.2 I think which might be the reason for it. The newer desktop apps redirect to the server’s SiteURL setting, previous versions did ignore that, so most likely, the configured SiteURL in your server is wrong.

You can check that in System Console → Environment → Web Server → Site URL. It needs to point to the exact URL (including scheme, ports, subdirectories) your desktop app will connect to.

Thanks a lot for your response. I had actually found a discussion related to this and validated the SiteURL, it seems to be correct.

In the meantime, I’ve gone and asked others to test it. I’ve asked them to download the same MacOS desktop client, version 5.3.1, and to my surprise they did not report the same issue.

I went through all the steps for a clean install again, no success.

I did get it working now though. After I add the server I have 3 tabs, Channels, Boards and Playbooks. I’ve actually never used the last 2. If I close the Boards and Playbooks tabs, I can successfully log in. I’m happy with that solution, in the sense that it works fine now, but clearly there’s something misconfigured, a permission issue or a broken legacy configuration…

Given that the issue is specifically with the Boards/Playbooks tabs (genuinely no idea what they’re even there for), does anyone have any idea what I could check further?

Interesting find - do you know which of these two is causing the problem or are both of them causing it?
I can see in your browser console that you’ve enabled boards and playbooks and the versions (7.9.2 for boards and 1.36.0 for playbooks) are fine. They’re part of the product now, but if you do not need those features, you can try to disable the plugins for the time being, although it would be interesting to see what exactly causes the blank pages for you.

Playbooks Documentation: Mattermost Playbooks — Mattermost documentation
Boards Documentation: Mattermost Boards — Mattermost documentation

There might be some cached content on your desktop app, though, which interferes with a newer plugin version. Can you try to delete the local caches? I’m not 100% sure of the full path to them, but they should be near the logs directory.