TokenProvider Object

Could you please provide some guidance on the use of TokenProvider.Outlook,getInstance().

It is unclear to me what the third parameter is.

@intradyn

It is refreshToken - OAuth 2.0 refresh token. Please check the detail from here:

Pointing me back to a page I have read many times is little help. How do I get a refresh token to provide? Once I have a TokenProvider I can get a refresh token, but I don’t have one yet.

@intradyn

We have logged your requirement in our issue tracking system as EMAILJAVA-35058. We will inform you via this forum thread once there is an update available on it.

@intradyn

The TokenProvider.Outlook.getInstance() uses legacy MS office resources.
You can use the AzureROPCTokenProvider helper class to access MS services via OAuth 2.0:

The OAuth 2.0 permissions to access Office365 via IMAP, POP3 or SMTP.
You need to apply correct API permissions and grant the admin consent:

image.png (19.2 KB)

In the API permissions / Add a permission wizard, select Microsoft Graph and then Delegated permissions to find the following permission scopes listed:

offline_access IMAP.AccessAsUser.All POP.AccessAsUser.All SMTP.Send

Imap client example:

ITokenProvider tokenProvider = new AzureROPCTokenProvider(OAuth.Tenant, OAuth.ClientId, OAuth.ClientSecret, User.EMail, User.Password,
        new String[] {
                "offline_access",
                "https://outlook.office.com/IMAP.AccessAsUser.All",
                "https://outlook.office.com/POP.AccessAsUser.All",
                "https://outlook.office.com/SMTP.Send"
        });

ImapClient client = new ImapClient(
        "outlook.office365.com",
        993,
        "test1@xxx.onmicrosoft.com",
        tokenProvider,
        SecurityOptions.SSLImplicit);

client.noop();

The AzureROPCTokenProvider helper class implements capabilities to retrieve refresh_token/access_token.
The refresh_token will be retrieved only with offline_access scope line.
Refresh Tokens description:

A post was split to a new topic: AzureROPCTokenProvider uses the password instead of client secret