当前位置: 首页 > news >正文

做资金盘 互助盘的网站亚马逊热带雨林

做资金盘 互助盘的网站,亚马逊热带雨林,wordpress按需求开发,长春建站方法一、背景说明 在已有的项目中,已经获取到了Graph的AccessToken并保存在内存里面。所以不希望再通过client secret或者certificate去创建GraphServiceClient对象。希望使用现有的token字符串来创建初始化创建GraphServiceClient从而来实现Graph其他API功能。 二、具体…
一、背景说明

在已有的项目中,已经获取到了Graph的AccessToken并保存在内存里面。所以不希望再通过client secret或者certificate去创建GraphServiceClient对象。希望使用现有的token字符串来创建初始化创建GraphServiceClient从而来实现Graph其他API功能。

二、具体实现

2.1 需要Java Graph SDK依赖 加入到pom.xml文件内

 <!-- Microsoft Graph SDK for Java --><dependency><groupId>com.microsoft.graph</groupId><artifactId>microsoft-graph</artifactId><version>[5.0,)</version></dependency><!-- Azure AD Authentication SDK for Java --><dependency><groupId>com.azure</groupId><artifactId>azure-identity</artifactId><version>[1.3,)</version></dependency>

2.2 代码片段

  public static GraphServiceClient initGraphServiceClient() {IAuthenticationProvider authProvider = new IAuthenticationProvider() {@Overridepublic CompletableFuture<String> getAuthorizationTokenAsync(URL requestUrl) {CompletableFuture<String> future = new CompletableFuture<>();future.complete(Your_AccessToken);return future;}};return GraphServiceClient.builder().authenticationProvider(authProvider).buildClient();}
三、测试

下面代码是实现调用创建GraphServiceClient,调用graph api发送带附件的邮件。

	public static String sendMail() {try {String mfrom = "xxxx@outlook.com";String to = "xxxx@outlook.com";GraphServiceClient<Request> graphClient = initGraphServiceClient();Message message = new Message();message.subject = "Meet for lunch?";ItemBody body = new ItemBody();body.contentType = BodyType.TEXT;body.content = "The new cafeteria is open.";message.body = body;LinkedList<Recipient> toRecipientsList = new LinkedList<Recipient>();Recipient toRecipients = new Recipient();EmailAddress emailAddress = new EmailAddress();emailAddress.address = to;toRecipients.emailAddress = emailAddress;toRecipientsList.add(toRecipients);message.toRecipients = toRecipientsList;// 构建附件LinkedList<Attachment> attachmentsList = new LinkedList<Attachment>();FileAttachment attachments = new FileAttachment();attachments.name = "hello word.txt";attachments.oDataType = "#microsoft.graph.fileAttachment";attachments.contentType = "text/plain";attachments.contentBytes = Base64.getDecoder().decode("SGVsbG8gV29ybGQh");attachmentsList.add(attachments);AttachmentCollectionResponse attachmentCollectionResponse = new AttachmentCollectionResponse();attachmentCollectionResponse.value = attachmentsList;AttachmentCollectionPage attachmentCollectionPage = new AttachmentCollectionPage(attachmentCollectionResponse, null);message.attachments = attachmentCollectionPage;// 以指定用户邮箱发送邮件graphClient.users(mfrom).sendMail(UserSendMailParameterSet.newBuilder().withMessage(message).withSaveToSentItems(true).build()).buildRequest().post();log.info("send email success");return "success";} catch (Exception e) {e.printStackTrace();log.error("send email error : {}", e.getMessage());return e.getMessage();}}

http://www.yayakq.cn/news/466642/

相关文章:

  • 呼和浩特市网站建设蝶恋花直播app下载安装
  • 做证明图片的网站1688货源网一件代发拼多多
  • 科技公司网站系统国外机械做的好的网站
  • 协会网站设计方案免费服务器建站
  • 新云网站模板哪些大型网站有做互联网金融
  • 哪个网站可以学做咸菜wordpress 无法自行修改密码
  • 易书网上书城网站建设方案seo网站关键词优化机构
  • 网站建设 腾重庆建设教育网站
  • 朝阳市网站公司平面设计师赚钱吗
  • 大潮建设集团有限公司 网站网站关键词优化服务
  • 阿里巴巴网站图片怎么做西八里庄网站建设
  • 网站开发技术框架虚拟主机管理系统
  • 十大网站网站维护开发合同
  • 百度做网站推广多少钱网站开发的工作内容
  • 个人网站必须备案吗wordpress wpadmin修改
  • 网站图片地址怎么做的成都网站建设多少费用
  • 好的php网站如何建设销售型企业网站
  • python做网站是不是特别慢关键词优化公司排行
  • 个人求职网站源代码南阳网站网站建设
  • 网站建设有哪三部专业网站的建设设行吗
  • 微商城网站建设多少钱黄石网站制作
  • 贵阳企业网站设计制作wordpress站点搬家
  • 石家庄房地产网站建设好的网站建设案例
  • 建设企业网站注意事项it外包公司招聘
  • 网站设计与开发范本电子商务营销渠道有哪些
  • 学网站建设能赚钱吗权威发布意思
  • 做外贸的零售网站排名函数
  • 中英双语网站制作网页原型的目的
  • 如何用域名建网站怎么在vk网站上做推广
  • 建站工作室开创者wordpress素材