Caused by: jakarta.mail.AuthenticationFailedException: OAUTH2 asked for more
at com.sun.mail.smtp.SMTPTransport$OAuth2Authenticator.doAuth(SMTPTransport.java:1121)
at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:924)
After changing scope to "https://mail.google.com/" for authorization, it works. But this scope will authorize
send, read, delete all emails.
This scope is too much, no difference from password authentication.
JavaMail oauth requires full mail scope for sending email via gmail.
Used scope "
https://www.googleapis.com/auth/gmail.send
" for authorization. and then got refresh and access token.Java mail:
Got error:
Caused by: jakarta.mail.AuthenticationFailedException: OAUTH2 asked for more at com.sun.mail.smtp.SMTPTransport$OAuth2Authenticator.doAuth(SMTPTransport.java:1121) at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:924)
After changing scope to "
https://mail.google.com/
" for authorization, it works. But this scope will authorizeThis scope is too much, no difference from password authentication.