Shared mailbox oauth access

Andrii Maslov 31 Reputation points
2020-11-13T12:48:44.697+00:00

Greetings,

I recently configured oauth authentication for my software in order to fetch/send emails from my outlook or office365 account. I'm using these endpoints

with such scopes: https://outlook.office.com/IMAP.AccessAsUser.All, https://outlook.office.com/SMTP.Send, offline_access, https://outlook.office.com/user.read.

Oauth login successful and both SMTP/IMAP connection tests passed for accounts main mailbox. But I need to access shared mailbox, that account has access to. According to your docs:

In case of shared mailbox access using OAuth, application needs to obtain the access token on behalf of a user but replace the userName field in the SASL XOAUTH2 encoded string with the email address of the shared mailbox.

That's all I need to do, in order for it to work. Although IMAP works fine, SMTP isn't working in this way and returns 535 5.7.3 authentication unsuccessful.

I'm new to office 365 and shared mailboxes, perhaps there is something I need to configure in office 365 admin center, or maybe add another scope? I've read that you shouldn't access shared mail box directly(I'm guessing setting password to mailboxes 'active user' and login like normal account) but I'm not sure why. So seems to me that changing email user in SASL XOAUTH2 encoded string is the only option, or is there any other way?

P.s.
License - office 365 business standard.

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,339 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Lydia Zhou - MSFT 2,371 Reputation points Microsoft Employee
    2020-11-16T06:20:39.173+00:00

    @Andrii Maslov

    I did some research, but cannot find other options to access shared mailbox using OAuth. Based on the official document, this should be the only suggested option.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Andrii Maslov 31 Reputation points
    2020-11-16T08:11:27.337+00:00

    @Lydia Zhou - MSFT

    I'm fine with that only option. The thing I don't get is why am I getting 535 5.7.3 authentication unsuccessful only through SMTP connection with OAuth.
    The basic authentication works fine for both IMAP/SMTP, the problem only with oauth. I haven't found any limitations in official documentations yet. Or maybe its not possible at all?

    Also I've noticed that Authenticated SMTP checkbox is absent in shared mailbox email settings compared to "active user" of that shared mailbox.
    Shared mailbox:
    40005-selection-239.png

    Active user of shared mailbox:
    40006-selection-238.png

    Can it be the reason?


  3. Lydia Zhou - MSFT 2,371 Reputation points Microsoft Employee
    2020-11-24T06:40:54.823+00:00

    @Andrii Maslov

    Did you also try the Full Access permission? The Full Access permission lets a user open the shared mailbox and act as the owner of that mailbox.
    You can set from EAC > Recipients > Shared > select your shared mailbox and click Mailbox delegation to grant Full Access permission.
    42111-620.png

    You also can use the following command to grant full access permission:

    Add-MailboxPermission -Identity "shared mailbox" -User username -AccessRights FullAccess -InheritanceType All  
    Get-MailboxPermission "shared mailbox"  
    

    Wait for a while to make sure it takes affect, then test to use OAuth authentication to connect with SMTP again.

    Additionally, did you assign a license to the shared mailbox?
    You can create a new shared mailbox without license to test again to see if the issue can be reproduced on the new one.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  4. Tejo Kumar 1 Reputation point
    2021-03-28T03:02:55.067+00:00

    I've a shared mailbox with the similar configuration as provided in the question. But instead of user being directly added to the shared mailbox as a member(to receive/send emails), we have a mail-enabled security group added as a member. The user and the shared mailbox both belong to the same security group.
    The IMAP fails with Oauth in this case. Basic auth works just fine. Also, If I add the user directly as a member, IMAP with oauth access token works fine.
    Why isn't the oauth access token working if the group is added to the mailbox as a member instead of the user.

    We're receiving the below error:
    User is authenticated but not connected.

    0 comments No comments