Rechercher

Ce contenu n'est pas disponible dans la langue sélectionnée.

Chapter 87. Mail Microsoft Oauth

download PDF

Since Camel 3.18.4.

The Mail Microsoft OAuth2 provides an implementation of org.apache.camel.component.mail.MailAuthenticator to authenticate IMAP/POP/SMTP connections and access to Email via Spring’s Mail support and the underlying JavaMail system.

87.1. Dependencies

Add the following dependency to your pom.xml for this component:

<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-mail-microsoft-oauth</artifactId>
</dependency>

Importing camel-mail-microsoft-oauth will automatically import camel-mail component.

87.2. Microsoft Exchange Online OAuth2 Mail Authenticator IMAP sample

To use OAuth, an application must be registered with Azure Active Directory. Follow the instructions to register a new application.

Procedure

  1. Enable the application to access Exchange mailboxes via client credentials flow. For more information, see Authenticate an IMAP, POP or SMTP connection using OAuth
  2. Once everything is set up, declare and register in the registry, an instance of org.apache.camel.component.mail.MicrosoftExchangeOnlineOAuth2MailAuthenticator.
  3. For Example, in a Spring Boot application:
@BindToRegistry("auth")
public MicrosoftExchangeOnlineOAuth2MailAuthenticator exchangeAuthenticator(){
    return new MicrosoftExchangeOnlineOAuth2MailAuthenticator(tenantId, clientId, clientSecret, "jon@doe.com");
}
  1. Then reference it in the Camel URI as follows:
 from("imaps://outlook.office365.com:993"
                    +  "?authenticator=#auth"
                    +  "&mail.imaps.auth.mechanisms=XOAUTH2"
                    +  "&debugMode=true"
                    +  "&delete=false")
Red Hat logoGithubRedditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez leBlog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

© 2024 Red Hat, Inc.