Normally to log-in into a shared mailbox of Exchange/Office365 special username had to be used:
client.Login(
@"Username@DomainName\SharedMailboxAlias",
"UserPassword");
Office365 allows accessing shared mailboxes when authenticated using OAuth2:
"In case of shared mailbox access using OAuth2, 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."
In other words:
client.LoginOAUTH2(
@"email address of the shared mailbox",
"userAccessToken);