summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-12-21 11:01:37 -0600
committerRobin Jarry <robin@jarry.cc>2022-12-21 21:23:16 +0100
commit8ce96f1716bca832b4ee1593aa3489adc932e2e9 (patch)
tree6c5bf185db2a47e09b5ca107f91b652caf90edc2
parent9cb67abce7f4dbd5288c123d571fa65e5b1e73f8 (diff)
downloadaerc-8ce96f1716bca832b4ee1593aa3489adc932e2e9.tar.gz
aerc-8ce96f1716bca832b4ee1593aa3489adc932e2e9.zip
smtp: remove requirement for oauthbearer token-endpoint
The SMTP configuration is slightly different between oauthbearer and xoauth2. The oauthbearer requires a token-endpoint, while xoauth2 does not. The IMAP version of oauthbearer also does not require a token-endpoint. If one is specified, the token is treated as a refresh token. Modify the SMTP usage to work the same way: a token is an access token unless a token-endpoint is specified Reported-by: Cameron Samak <csamak@apache.org> Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--commands/compose/send.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/commands/compose/send.go b/commands/compose/send.go
index 7306bef8..9edb168e 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -325,14 +325,13 @@ func newSaslClient(auth string, uri *url.URL) (sasl.Client, error) {
OAuth2: oauth2,
Enabled: true,
}
- if bearer.OAuth2.Endpoint.TokenURL == "" {
- return nil, fmt.Errorf("No 'TokenURL' configured for this account")
- }
- token, err := bearer.ExchangeRefreshToken(password)
- if err != nil {
- return nil, err
+ if bearer.OAuth2.Endpoint.TokenURL != "" {
+ token, err := bearer.ExchangeRefreshToken(password)
+ if err != nil {
+ return nil, err
+ }
+ password = token.AccessToken
}
- password = token.AccessToken
saslClient = sasl.NewOAuthBearerClient(&sasl.OAuthBearerOptions{
Username: uri.User.Username(),
Token: password,