xoauth2

package
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package xoauth2 is Go library for generating XOAuth2 strings (for use in XOAUTH2 SASL auth schemes for IMAP/SMTP)

Copied from https://github.com/sqs/go-xoauth2

Index

Constants

View Source
const XOAuth2 = "XOAUTH2"

The XOAUTH2 mechanism name.

Variables

This section is empty.

Functions

func NewXOAuth2Client

func NewXOAuth2Client(opt *XOAuth2Options) *xoauth2Client

An implementation of the OAUTHBEARER authentication mechanism, as described in RFC 7628.

func OAuth2String

func OAuth2String(user, accessToken string) string

OAuth2String generates an unencoded XOAuth2 string of the form

"user=" {User} "^Aauth=Bearer " {Access Token} "^A^A"

as defined at https://developers.google.com/google-apps/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism (^A represents a Control+A (\001)).

The function XOAuth2String in this package returns the base64 encoding of this string.

func XOAuth2String

func XOAuth2String(user, accessToken string) string

XOAuth2String generates a base64-encoded XOAuth2 string suitable for use in SASL XOAUTH2, as defined at https://developers.google.com/google-apps/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism.

(Use the base64 encoding mechanism defined in RFC 4648.)

Types

type XOAuth2Error

type XOAuth2Error struct {
	Status  string `json:"status"`
	Schemes string `json:"schemes"`
	Scope   string `json:"scope"`
}

func (*XOAuth2Error) Error

func (err *XOAuth2Error) Error() string

Implements error

type XOAuth2Options

type XOAuth2Options struct {
	Username     string
	AccessToken  string
	RefreshToken string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL