digipoauth

package module
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MPL-2.0 Imports: 18 Imported by: 0

README

rclone-digiposte

This go package aims to provide oauth2 endpoint for digiposte.fr. digiposte.fr is a french service provided by La Poste (the french post office) to store and share documents. It is similar to Dropbox, Google Drive, etc.

Officially, digiposte.fr does not provide any oauth2 endpoint. This package is a workaround to connect to digiposte.fr using oauth2.

Usage

Get a token

Documentation

Index

Constants

View Source
const (
	AuthorizePath = "/authorize"
	TokenPath     = "/token"

	ReadTimeout  = 5 * time.Second
	WriteTimeout = 5 * time.Minute
)
View Source
const RefreshTokenLength = 32

Variables

View Source
var ErrNilCredentials = errors.New("nil credentials")

Functions

This section is empty.

Types

type AccessGenerator

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

func (*AccessGenerator) Token

func (ag *AccessGenerator) Token(
	ctx context.Context,
	generateBasic *oauth2v4.GenerateBasic,
	isGenRefresh bool,
) (string, string, error)

type Credentials

type Credentials struct {
	Username  string
	Password  string
	OTPSecret string
}

type InvalidOptionError

type InvalidOptionError struct {
	Name string
	Err  error
}

func (*InvalidOptionError) Apply

func (e *InvalidOptionError) Apply(interface{}) error

func (*InvalidOptionError) Error

func (e *InvalidOptionError) Error() string

func (*InvalidOptionError) Unwrap

func (e *InvalidOptionError) Unwrap() error

type LoginMethod

type LoginMethod interface {
	Login(ctx context.Context, creds *Credentials) (*oauth2.Token, []*http.Cookie, error)
}

type LoginMethodFunc

type LoginMethodFunc func(ctx context.Context, creds *Credentials) (*oauth2.Token, []*http.Cookie, error)

func (LoginMethodFunc) Login

func (f LoginMethodFunc) Login(ctx context.Context, creds *Credentials) (*oauth2.Token, []*http.Cookie, error)

type Option

type Option interface {
	Apply(instance interface{}) error
}

type OptionFunc

type OptionFunc func(instance interface{}) error

func (OptionFunc) Apply

func (f OptionFunc) Apply(instance interface{}) error

type RequiredFieldError

type RequiredFieldError struct {
	Field string
}

func (*RequiredFieldError) Error

func (e *RequiredFieldError) Error() string

type Server

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

Server is a local web server for collecting auth.

func NewServer

func NewServer(
	setter digiconfig.Setter,
	clientID, clientSecret, redirectURL string,
	loginMethod LoginMethod,
	logger *log.Logger,
) (*Server, error)

StartServer starts a local webserver to receive the auth.

func (*Server) AuthorizeURL

func (s *Server) AuthorizeURL() string

AuthorizeURL returns the URL to the authorize endpoint.

func (*Server) Close

func (s *Server) Close() error

Close closes the server.

func (*Server) Start

func (s *Server) Start() error

Start starts the server.

func (*Server) TokenURL

func (s *Server) TokenURL() string

TokenURL returns the URL to the token endpoint.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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