使用OAUTH2在java struts2中发送电子邮件 [英] Sending email in java struts2 using OAUTH2

查看:331
本文介绍了使用OAUTH2在java struts2中发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我需要使用OAUTH2以java代码发送电子邮件。我从 Google API控制台 [<}获得了客户端ID和客户端密码a href =https://console.developers.google.com/apis/credentialstarget =_ blanktitle =New Window> ^ ]并尝试获取 [ ^ ]我从哪里找到3个令牌,

Hello,

I need to send emails in java code using OAUTH2. I have got client Id and client secret from Google API Console[^] and trying to get authorization code at [^] from where I have found 3 tokens,

Authorization code

Refresh token

Access token

。当我用授权代码或访问令牌替换Oauth令牌时,我发现无效用户ID和密码出错。如果有人可以使用OAUTH2提供运行javaMail的示例,我将非常感激。

有些教程建议使用Python脚本,但我不知道天气可以在java中运行python脚本并获得输出再次用Java。

谢谢



我尝试过:



我试过执行类似于

的java代码[ ^ ]但会显示无效的用户ID和密码错误。

. When I replace Oauth token with authorization code or access token, I found error for invalid user id and password. I will be really thankful if someone can provide running example of javaMail using OAUTH2.
Some tutorials recommend using Python scripts, but I have no clue that weather it is possible to run python script in java and obtain output again in Java.
Thank you

What I have tried:

I have tried executing java code similar to
[^] but invalid user id and password error is displayed.

推荐答案

您是否尝试过Google自己的Java Client Lib?我会给你 google java client api - Google搜索 [ ^ ]因为它指向一些关键页面。他们的说明和样本非常好。
Have you tried Google's own Java Client Lib? I'll give you google java client api - Google Search[^] as it points to a number of key pages for you. Thier instructions and samples are very good.


我也会尝试,但我之前尝试发送电子邮件的java代码在部署后面临问题。我使用亚马逊服务来托管我的Web应用程序,并且托管服务器通常会阻止邮件请求。因此,我正在寻找更安全的方法来发送电子邮件,没有任何问题。

感谢您的回复
I will try it also, but the java codes I was trying earlier to send emails were facing issues after deployment. I am using Amazon services for hosting of my web application and often mail requests are blocked by hosting server. Therefore I am searching for more secure method to send emails without any problem.
Thanks for your response


这篇关于使用OAUTH2在java struts2中发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆