OAuth2 support for O365 Code examples access

I could not download the files from the links provided. Same message here: Sorry, this file is private. Only visible to topic owner and staff members.

How can I have access to those examples?

Thank you

@inabella Due to the security reasons attachments in the forum can be accessed only by topic starter and Aspose staff.
Could you please share the link with the example you need to access?

Thank you for such a quick reply. I’m sorry, I’ve forgot to put that info.

I’d like to ask for code prompts for IMAP, POP connection to Office 365 with SSL, please. As far as I understand, the file should have a name of EWSModernAuthenticationImapSmtp.zip.

Thank you.

@inabella Looks like your question is related to Aspose.Email. I will move it to the appropriate forum. My colleagues will rely you soon.

1 Like

@inabella

Please download code examples from this post. Hope this helps you.

EWSModernAuthenticationImapSmtp.zip (3.9 KB)
EWSModernAuthenticationApp.zip (3.4 KB)
EWSModernAuthenticationDelegated.zip (3.6 KB)

1 Like

Thank you very much for the samples provided.
May I ask you additionally send the Authentication code in .vb?

thank you

@inabella

Please spare us some time. We will provide you the VB code example.

@inabella

Please use the attached VB code examples. Hope this helps you.
EWSModernAuthenticationImapSmtpVBCode.zip (110.4 KB)
EWSModernAuthenticationAppVBCode.zip (109.0 KB)

Dear Aspose team,

Thank you for providing the code sample in .vb.
We still have issues with OAuth2.0 connectivity with our application. However, the authentication process is different - the access to the server is granted via access token and then via Refresh token.

May we ask you to provide the code sample in .vb with the full OAuth2.0 process using both tokens?
We have a ticket with Microsoft. At the same time we would like to rule out the possible issues with connectivity on Aspose side.

Thank you,
Inna

@inabella

Please read the following detail to login into Office 365 account using Modern Authentication. Hope this helps you.

How To Enable or disable modern authentication

To use modern authentication, make sure that it is enabled. Modern authentication is enabled by default in Exchange Online. For tenants created before August 1, 2017, modern authentication is turned off by default.
In the Microsoft 365 admin center at https://admin.microsoft.com, go Settings > Org Settings > Modern Authentication. In the Modern authentication flyout that appears, you can identify the protocols that no longer require Basic authentication.
For new Office 365 tenants in Azure, Basic Authentication is disabled by default for all applications. In this case, the text will be displayed in this section.

Your organization has security defaults enabled, which means modern authentication to Exchange Online is required, and basic authentication connections are blocked. You must turn off security defaults in the Azure portal before you can change any settings here.

You can enable Basic Auth support for tenant from the Azure portal (Azure Active Directory → Properties → Manage Security defaults → Enable Security defaults = No ).
For more information, see the documentation on Enable or disable modern authentication for Outlook in Exchange Online | Microsoft Learn

How To use modern authentication with EwsClient

To use modern authentication with EwsClient the following is required:

  1. App registration with Azure Active Directory.
  2. Adding code to get an authentication token from a token server.
  3. Using the token to authenticate.

Note: There are two types of permissions that can be used to access EWS. Choose a specific type of permission, depending on the app you are creating:

  • Delegated permissions are used by apps that have a signed-in user present. For these apps, either the user or an administrator consents to the permissions that the app requests. In other words, when you connect to the service, a dialog window will appear to enter username and password. App can never have more privileges than the signed-in user.
  • Application permissions are used by apps that run without a signed-in user present, for example, apps that run as background services or daemons. Only an administrator can consent to application permissions.

Refer to Microsoft documentation for more information: Authenticate an EWS application by using OAuth | Microsoft Learn

App registration with Azure Active Directory

The registration procedure depends on the type of permission selected. To register your app, refer to the Microsoft documentation: