| 1 | package smtpscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/email/smtp`/ |
| 2 | |
| 3 | import ( |
| 4 | "net/smtpscip-go gomod github.com/golang/go/src . `net/smtp`/" |
| 5 | ) |
| 6 | |
| 7 | type oauth2Authscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/email/smtp`/oauth2Auth# struct { |
| 8 | usernamescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/email/smtp`/oauth2Auth#username., accessTokenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/email/smtp`/oauth2Auth#accessToken. string |
| 9 | } |
| 10 | |
| 11 | // OAuth2Auth returns an Auth that implements the SASL XOAUTH2 authentication |
| 12 | // as per https://developers.google.com/gmail/imap/xoauth2-protocol. |
| 13 | // It assumes the provided password is a valid OAuth2 access token. |
| 14 | // Token refresh or complex challenge-response flows are not supported. |
| 15 | func OAuth2Authscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/email/smtp`/OAuth2Auth().(username, accessToken string) smtpscip-go gomod github.com/golang/go/src . `net/smtp`/.Authscip-go gomod github.com/golang/go/src . `net/smtp`/Auth# { |
| 16 | return &oauth2Authscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/email/smtp`/oauth2Auth#{username, accessToken} |
| 17 | } |
| 18 | |
| 19 | func (a *oauth2Authscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/email/smtp`/oauth2Auth#) Nextscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/email/smtp`/oauth2Auth#Next().(_ []byte, _ bool) ([]byte, error) { |
| 20 | return nil, nil |
| 21 | } |
| 22 | |
| 23 | func (a *oauth2Authscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/email/smtp`/oauth2Auth#) Startscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/email/smtp`/oauth2Auth#Start().(_ *smtpscip-go gomod github.com/golang/go/src . `net/smtp`/.ServerInfoscip-go gomod github.com/golang/go/src . `net/smtp`/ServerInfo#) (string, []byte, error) { |
| 24 | resp := []byte("user=" + a.usernamescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/email/smtp`/oauth2Auth#username. + "\x01auth=Bearer " + a.accessTokenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/email/smtp`/oauth2Auth#accessToken. + "\x01\x01") |
| 25 | |
| 26 | return "XOAUTH2", resp, nil |
| 27 | } |