'JavaMail oauth requires full mail scope for sending email via gmail

JavaMail oauth requires full mail scope for sending email via gmail.

Used scope "https://www.googleapis.com/auth/gmail.send" for authorization. then get refresh and access token.

Java mail:

transport.connect(host, port, username, access_token);

Got error:

Oauth asks for more

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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source