81.2. Microsoft Exchange Online OAuth2 Mail Authenticator IMAP 示例


要使用 OAuth,应用程序必须使用 Azure Active Directory 注册。按照说明注册新应用程序。

流程

  1. 使应用程序能够通过客户端凭证流访问 Exchange 邮箱。如需更多信息,请参阅使用 OAuth 验证 IMAP、POP 或 SMTP 连接
  2. 设置所有内容后,在 registry 中声明和注册,即 org.apache.camel.component.mail.MicrosoftExchangeOnlineOAuth2MailAuthenticator 实例。
  3. 例如,在 Spring Boot 应用程序中:
@BindToRegistry("auth")
public MicrosoftExchangeOnlineOAuth2MailAuthenticator exchangeAuthenticator(){
    return new MicrosoftExchangeOnlineOAuth2MailAuthenticator(tenantId, clientId, clientSecret, "jon@doe.com");
}
Copy to Clipboard Toggle word wrap
  1. 然后,在 Camel URI 中引用它,如下所示:
 from("imaps://outlook.office365.com:993"
                    +  "?authenticator=#auth"
                    +  "&mail.imaps.auth.mechanisms=XOAUTH2"
                    +  "&debugMode=true"
                    +  "&delete=false")
Copy to Clipboard Toggle word wrap
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部