Nextcloud Mail App: Issues with Microsoft 365 OAuth Configuration and Account Linking
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1k
- Forks
- 348
- Avg merge
- 12h 28m
- Merged PRs (30d)
- 91
Description
Steps to reproduce
- Have configured MS OAuth client ID and secret in the admin settings as per [these instructions].(https://docs.nextcloud.com/server/latest/admin_manual/groupware/mail.html#xoauth2-authentication-with-microsoft-azure-ad)
- After that when adding a new Microsoft 365 Account in the mail app, once Name, Mail Address, and Password have been filled in, it shows the message: "Account created. Please follow the pop-up instructions to link your Google account.", even though it's not a Google Account. Anyways when the pop-up appears, the button first says "Awaiting User Consent" then the status shows as "Authorization pop-up closed" and signing in and filling up all the info in the pop-up from Microsoft 365 is completed but nothing happens related to logging in even though the pop-up says "Account connected"
"You can close this window".
Expected behavior
I should be able to log in to my Microsoft 365 Account.
Actual behavior
It shows the message: "Account created. Please follow the pop-up instructions to link your Google account.", even though it's not a Google Account. Anyways when the pop-up appears, it shows the status as "Authorization pop-up closed" and signing in and filling up all the info in the pop-up from Microsoft 365 is completed but nothing happens related to logging in even though the pop-up says "Account connected"
"You can close this window"
Mail app version
3.4.6
Mailserver or service
Microsoft 365
Operating system
Ubuntu 22.04.3 LTS
PHP engine version
PHP 8.2
Web server
None
Database
PostgreSQL
Additional info
Here's the latest log for the mail app from the logging section:
`[mail] Warning: OCA\Mail\Exception\ClientException: Account 66 does not exist or you don't have permission to access it at <>
- /var/www/html/custom_apps/mail/lib/Controller/MicrosoftIntegrationController.php line 138
OCA\Mail\Service\AccountService->find("john", 66) - /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 230
OCA\Mail\Controller\MicrosoftIntegrationController->oauthRedirect("0.AVAA32RN4P49b ... 4", "66", "825012c9-4b24-40ad-a899-0caa9f968768", null) - /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 137
OC\AppFramework\Http\Dispatcher->executeController(["OCA\Mail\Con ... "], "oauthRedirect") - /var/www/html/lib/private/AppFramework/App.php line 183
OC\AppFramework\Http\Dispatcher->dispatch(["OCA\Mail\Con ... "], "oauthRedirect") - /var/www/html/lib/private/Route/Router.php line 315
OC\AppFramework\App::main("OCA\Mail\Cont ... r", "oauthRedirect", ["OC\AppFramewo ... "], ["mail.microsoft ... "]) - /var/www/html/lib/base.php line 1068
OC\Route\Router->match("/apps/mail/integration/microsoft-auth") - /var/www/html/index.php line 36
OC::handleRequest()
GET /apps/mail/integration/microsoft-auth?code=0.AVAA32RN4P49bEWWuNNnvfEjfFnWwAtrFrZPvWyvpd9BsaBQAIg.AgABAAIAAAAmoFfGtYxvRrNriQdPKIZ-AgDs_wUA9P-bRuZenv9c2obZiTgYhjkDY7fxW08xvLmOF9fpaKKNCuepmCre0mqsBNp5kPZeZwh4qNB5HRtro0ErjzwAljV2KrFnELaEmrJE_xoLIQGI0TgbV-BTg8S7KzI3rbIStM0D61orit0xS1-tE5k5FzS0GehTsfjfi1pEuMZMZSTjGM9ErkXXIBt6pJfXjXQ6-9qeVcDU5jhsm1epC_5mwUrcT3CPlUs3-OODRTKbvQW9idHGztxlml3nlNAjPPhpif-h66y4paBYCaQeZSRrWOKeEvm0KkHtpq6WQBHhLkm5XYueEJM-vAmFvo13xHdomCTB3WvSTu6cAy8X_1BzJbw7Zy0GxzBBH0MQ2yTDQXyfMcDZ3Vqz8A5DpDBRtcmnTYZvJ06YxS6HljlZaAyF517BrXaOtHbSleAAATZc9Vr_B_dug9yS1AistFJCxecukZZR3O7vofY-9r8w4qgWSvw1XhQ751Di8gE5Y24zuTq8J7JsXRMw7M1l68TaD58qoU5JJXCCdD13VAGezCuRQsVWGQrlZqH9mp379o23iuXYHFJb3xrfbLImlRBdx7M3GILFt2M3yrXoOM61dBIcmWt3_fwP6gImrZP7UrNcxJftUZi3jjYZymxGHiFt2jOcKRY3OUaDckOTjT9lQfFivniO-rhPSh4Iy8jz1Z_yCcMduSR-lqr3ZhD65xzo4RUMbNeqjm4BtcC9zIOyiJ7InzPQBF9Qo6vBacnzQcr2fGkYDmsQTLW5jBGXrz5-PujDjmhnTezwd4SQIM9zS-9p-7bU-zyDxoMRKzMgOT6vLTHzu6Oh6j_MRKLQOnkKEXp5sutNmGNFcsiGpmTd2GoFnLCLic_-RBMPWZjf9BME2R2_pRhxcsuIqEHVo2aXlCMuXMk3CZ6YlaYIG0NUicSwuP9yVvnMIBfS2Vv_WDYtMHTbU3PpKUDbaFIUdm8-WncAFYkysHYHg76qNIYLdQK1AewezD2s4OIgBc34g169zt8S6jJf_CezkP9u79NKM_OrEtAzG5ZxWibMgsYxGEDXeIvPmIPlkFAV_u4&state=66&session_state=825012c9-4b24-40ad-a899-0caa9f968768
from xx.xx.xxx.xx by john at 2023-12-11T21:29:12+00:00`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting custom_apps/mail/lib/Controller/MicrosoftIntegrationController.php around line 138 and trace the Microsoft OAuth redirect using the provided log and reproduction steps. Verify how the account ID is passed and resolved during the callback; done means a Microsoft 365 account can complete authorization and link successfully without the Google-specific message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100