Documentation ¶
Index ¶
- Constants
- func Config(id, name string, m configmap.Mapper, config *oauth2.Config, ...) error
- func ConfigErrorCheck(id, name string, m configmap.Mapper, ...) error
- func ConfigNoOffline(id, name string, m configmap.Mapper, config *oauth2.Config, ...) error
- func Context(client *http.Client) context.Context
- func GetToken(name string, m configmap.Mapper) (*oauth2.Token, error)
- func PutToken(name string, m configmap.Mapper, token *oauth2.Token, newSection bool) error
- type AuthError
- type AuthResponseData
- type Renew
- type TokenSource
Constants ¶
const ( // TitleBarRedirectURL is the OAuth2 redirect URL to use when the authorization // code should be returned in the title bar of the browser, with the page text // prompting the user to copy the code and paste it in the application. TitleBarRedirectURL = "urn:ietf:wg:oauth:2.0:oob" // RedirectURL is redirect to local webserver when active RedirectURL = "http://" + bindAddress + "/" // RedirectPublicURL is redirect to local webserver when active with public name RedirectPublicURL = "http://localhost.rclone.org:" + bindPort + "/" // RedirectLocalhostURL is redirect to local webserver when active with localhost RedirectLocalhostURL = "http://localhost:" + bindPort + "/" // AuthResponse is a template to handle the redirect URL for oauth requests AuthResponse = `` /* 750-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func Config ¶
func Config(id, name string, m configmap.Mapper, config *oauth2.Config, opts ...oauth2.AuthCodeOption) error
Config does the initial creation of the token
It may run an internal webserver to receive the results
func ConfigErrorCheck ¶
func ConfigErrorCheck(id, name string, m configmap.Mapper, errorHandler func(*http.Request) AuthError, config *oauth2.Config, opts ...oauth2.AuthCodeOption) error
ConfigErrorCheck does the same as Config, but allows the backend to pass a error handling function This function gets called with the request made to rclone as a parameter if no code was found
func ConfigNoOffline ¶
func ConfigNoOffline(id, name string, m configmap.Mapper, config *oauth2.Config, opts ...oauth2.AuthCodeOption) error
ConfigNoOffline does the same as Config but does not pass the "access_type=offline" parameter.
Types ¶
type AuthResponseData ¶
type AuthResponseData struct { OK bool // Failure or Success? Code string // code to paste into rclone config AuthError }
AuthResponseData can fill the AuthResponse template
type Renew ¶
type Renew struct {
// contains filtered or unexported fields
}
Renew allows tokens to be renewed on expiry if uploads are in progress.
func NewRenew ¶
func NewRenew(name string, ts *TokenSource, run func() error) *Renew
NewRenew creates a new Renew struct and starts a background process which renews the token whenever it expires. It uses the run() call to run a transaction to do this.
It will only renew the token if the number of uploads > 0
type TokenSource ¶
type TokenSource struct {
// contains filtered or unexported fields
}
TokenSource stores updated tokens in the config file
func NewClient ¶
func NewClient(name string, m configmap.Mapper, oauthConfig *oauth2.Config) (*http.Client, *TokenSource, error)
NewClient gets a token from the config file and configures a Client with it. It returns the client and a TokenSource which Invalidate may need to be called on
func NewClientWithBaseClient ¶
func NewClientWithBaseClient(name string, m configmap.Mapper, config *oauth2.Config, baseClient *http.Client) (*http.Client, *TokenSource, error)
NewClientWithBaseClient gets a token from the config file and configures a Client with it. It returns the client and a TokenSource which Invalidate may need to be called on. It uses the httpClient passed in as the base client.
func (*TokenSource) Invalidate ¶
func (ts *TokenSource) Invalidate()
Invalidate invalidates the token
func (*TokenSource) OnExpiry ¶
func (ts *TokenSource) OnExpiry() <-chan time.Time
OnExpiry returns a channel which has the time written to it when the token expires. Note that there is only one channel so if attaching multiple go routines it will only signal to one of them.