auth

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllScopes = []string{

	"https://www.googleapis.com/auth/gmail.readonly",
	"https://www.googleapis.com/auth/gmail.send",
	"https://www.googleapis.com/auth/gmail.modify",

	"https://www.googleapis.com/auth/calendar.readonly",
	"https://www.googleapis.com/auth/calendar.events",

	"https://www.googleapis.com/auth/drive.readonly",
	"https://www.googleapis.com/auth/drive.file",

	"https://www.googleapis.com/auth/documents.readonly",
	"https://www.googleapis.com/auth/documents",

	"https://www.googleapis.com/auth/spreadsheets",

	"https://www.googleapis.com/auth/presentations.readonly",
	"https://www.googleapis.com/auth/presentations",

	"https://www.googleapis.com/auth/tasks.readonly",
	"https://www.googleapis.com/auth/tasks",

	"https://www.googleapis.com/auth/chat.spaces.readonly",
	"https://www.googleapis.com/auth/chat.messages",
	"https://www.googleapis.com/auth/chat.messages.create",

	"https://www.googleapis.com/auth/forms.responses.readonly",

	"https://www.googleapis.com/auth/userinfo.email",
}

AllScopes contains all Google API scopes required by gws. We request all scopes upfront so users only need to authenticate once.

Functions

func DeleteToken

func DeleteToken() error

DeleteToken removes the token file.

func GetTokenSource

func GetTokenSource(ctx context.Context, clientID, clientSecret string, token *oauth2.Token) oauth2.TokenSource

GetTokenSource returns a token source that automatically refreshes the token.

func LoadToken

func LoadToken() (*oauth2.Token, error)

LoadToken loads the OAuth token from the token file.

func SaveToken

func SaveToken(token *oauth2.Token) error

SaveToken saves the OAuth token to the token file with secure permissions.

func TokenExists

func TokenExists() bool

TokenExists checks if a token file exists.

Types

type OAuthClient

type OAuthClient struct {
	// contains filtered or unexported fields
}

OAuthClient handles the OAuth2 authentication flow.

func NewOAuthClient

func NewOAuthClient(clientID, clientSecret string) *OAuthClient

NewOAuthClient creates a new OAuth client with the given credentials.

func (*OAuthClient) GetConfig

func (c *OAuthClient) GetConfig() *oauth2.Config

GetConfig returns the OAuth2 config for creating authenticated clients.

func (*OAuthClient) Login

func (c *OAuthClient) Login(ctx context.Context) (*oauth2.Token, error)

Login performs the OAuth2 authorization flow with PKCE.

Jump to

Keyboard shortcuts

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