Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
and
Access token
. 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.
Posted
Updated 23-Feb-17 19:03pm

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.
 
Share this answer
 
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
 
Share this answer
 
Comments
Graeme_Grant 24-Feb-17 1:12am    
It may be an AWS configuration issue. I haven't used AWS, so I can't suggest what is required. I am sure they'll have information to help you.
Graeme_Grant 24-Feb-17 1:13am    
Also, when replying, press the Reply button next to the user's name and not Add your solution here
Member 12929639 24-Feb-17 1:14am    
ok.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900