이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 88. Mail Microsoft Oauth
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.
88.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>
<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.
88.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
- Enable the application to access Exchange mailboxes via client credentials flow. For more information, see Authenticate an IMAP, POP or SMTP connection using OAuth
-
Once everything is set up, declare and register in the registry, an instance of
org.apache.camel.component.mail.MicrosoftExchangeOnlineOAuth2MailAuthenticator. - For Example, in a Spring Boot application:
@BindToRegistry("auth")
public MicrosoftExchangeOnlineOAuth2MailAuthenticator exchangeAuthenticator(){
return new MicrosoftExchangeOnlineOAuth2MailAuthenticator(tenantId, clientId, clientSecret, "jon@doe.com");
}
@BindToRegistry("auth")
public MicrosoftExchangeOnlineOAuth2MailAuthenticator exchangeAuthenticator(){
return new MicrosoftExchangeOnlineOAuth2MailAuthenticator(tenantId, clientId, clientSecret, "jon@doe.com");
}
- 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")
from("imaps://outlook.office365.com:993"
+ "?authenticator=#auth"
+ "&mail.imaps.auth.mechanisms=XOAUTH2"
+ "&debugMode=true"
+ "&delete=false")