Setting up OAuth for Thunderbird: The redirect_uri parameter is missing or does not match the client registration

Your question

I am trying to set up Thunderbird 159 to use OAuth for my Stalwart 1.0.1 server.
I have set

"redirectionEndpoint": "http://127.0.0.1/"

in my OAuthProvider in Thunderbird, and added http://127.0.0.1/ to the Redirection URIs in the OAuth client settings for Thunderbird in Stalwart.

But when I try to add the account in Thunderbird, I get an error from Stalwart in my browser that reads:

The redirect_uri parameter is missing or does not match the client registration.

Any ideas what I should do?

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

Hi,

Stalwart compares the redirect_uri in the authorization request against the redirectUris of the OAuthClient whose clientId matches the client_id Thunderbird sends. A registered http://127.0.0.1/ accepts any port, so http://127.0.0.1:54321/ matches too, but the path still has to be identical (redirect URI rules). So either Thunderbird is sending a different redirect_uri than the one you configured, or its client_id points at a different client than the one you edited.

The error page you see in the browser has the whole authorization request in its address bar. Could you paste that URL here (the state and code_challenge values can be blanked out)? The client_id and redirect_uri parameters in it will show which side doesn’t match.

The URL is,

https://mail.example.dk/login?response_type=code&client_id=tb&scope=basic+profile+offline_access&state=XXX&code_challenge_method=S256&code_challenge=XXX&login_hint=username%40example.dk&redirect_uri=http%3A%2F%2F127.0.0.1%3A43363

I have double checked that TB will use client id tb and that is indeed the id of the client I have set up.

Setting the redirect_uri to http://127.0.0.1/example sovlved the problem.