0 votes

Good day, I would like to confirm how can we implement the OAuth 2.0 with office 365?
We have windows form app that will connect to each client's credentials, from the documentation link: https://www.limilabs.com/blog/oauth2-office365-exchange-imap-pop3-smtp do we need to do this on every client?

by (780 points)

1 Answer

+1 vote

I'm not sure I understand your question, especially what do you mean by 'client' exactly.

There are several OAuth 2.0 flows, used for different scenarios/requirements. You need to decide which one you should be using:

Daemons/Services: Password grant (MFA/2FA must be turned off for this account):

Daemons/Services: Client credential flow:

Web apps (requires user interaction):

Standalone devices (requires very little interaction):

Desktop apps (requires user interaction):

by (298k points)
Hello, thank you for your response.
For example, we had clients a,b, and c with their own azure credentials. without using the OAuth2.0 we connect to the IMAP by their own credentials (username & password) using UseBestLogin method. how can we implement the same thing with OAuth2.0?
Your options are:
- use regular desktop app flow and authenticate 3 times;
- use password grant (similar to what you have right now);
- if those are corporate accounts, you can add permissions to all 3 mailboxes to your principal and use a client credential flow;
Hello, Good day.
I follow the steps from the documentation: https://www.limilabs.com/blog/oauth2-office365-exchange-imap-pop3-smtp

I've got this error:
MsalUiRequiredException: No account or login hint was passed to the AcquireTokenSilent call.

What did I miss?
This is perfectly normal. MsalUiRequiredException is thrown when user interaction is needed - it is handled in the code.
What shall I do to prevent this kind of exception?
I have provided the correct client id and tenant id.
It is handled in the code - invoke AcquireTokenInteractive method.