mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-09 15:32:54 +01:00
8673addaf0
Microsoft also accept the same protocol used for Google servers
24 lines
556 B
Go
24 lines
556 B
Go
// SPDX-FileCopyrightText: Copyright (c) 2023 The go-mail Authors
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package smtp
|
|
|
|
type xoauth2Auth struct {
|
|
username, token string
|
|
}
|
|
|
|
func XOAuth2Auth(username, token string) Auth {
|
|
return &xoauth2Auth{username, token}
|
|
}
|
|
|
|
func (a *xoauth2Auth) Start(_ *ServerInfo) (string, []byte, error) {
|
|
return "XOAUTH2", []byte("user=" + a.username + "\x01" + "auth=Bearer " + a.token + "\x01\x01"), nil
|
|
}
|
|
|
|
func (a *xoauth2Auth) Next(_ []byte, more bool) ([]byte, error) {
|
|
if more {
|
|
return []byte(""), nil
|
|
}
|
|
return nil, nil
|
|
}
|