auth

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseService

type DatabaseService interface {
	SaveTokenConfig(config *database.TokenConfig) error
	GetTokenConfig() (*database.TokenConfig, error)
}

DatabaseService interface defines the methods needed from database service

type Service

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

Service handles OAuth2 authentication for Google Drive API

func NewService

func NewService(clientID, clientSecret string, redirectURL string, dbService DatabaseService) *Service

NewService creates a new auth service

func (*Service) ExchangeToken

func (s *Service) ExchangeToken(authCode string) error

ExchangeToken exchanges authorization code for tokens and saves them

func (*Service) GetAuthURL

func (s *Service) GetAuthURL() string

GetAuthURL returns the authorization URL for OAuth2 flow

func (*Service) GetClient

func (s *Service) GetClient() (*oauth2.Config, *oauth2.Token, error)

GetClient returns an authenticated HTTP client

func (*Service) GetTokenInfo

func (s *Service) GetTokenInfo() (*TokenInfo, error)

GetTokenInfo returns information about the current token

func (*Service) GetValidToken

func (s *Service) GetValidToken() (*oauth2.Token, error)

GetValidToken returns a valid token, refreshing if necessary

func (*Service) RefreshToken

func (s *Service) RefreshToken(token *oauth2.Token) (*oauth2.Token, error)

RefreshToken refreshes the token and save it to the database

func (*Service) ValidateToken

func (s *Service) ValidateToken() error

ValidateToken validates the stored token by making a test API call

type TokenInfo

type TokenInfo struct {
	HasToken bool      `json:"has_token"`
	Expiry   time.Time `json:"expiry,omitempty"`
	Valid    bool      `json:"valid"`
}

TokenInfo represents token information for display

Jump to

Keyboard shortcuts

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