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.


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.


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.


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[] {

ImapClient client = new ImapClient(


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