Documentation ¶
Index ¶
- Constants
- Variables
- func NewDriver(policy *model.Policy) (driver.Handler, error)
- type APIError
- type Client
- func (client *Client) AccessToken() string
- func (client *Client) OAuthURL(ctx context.Context, scope []string) string
- func (client *Client) ObtainToken(ctx context.Context, code, refreshToken string) (*Credential, error)
- func (client *Client) UpdateCredential(ctx context.Context, isSlave bool) error
- type Credential
- type Driver
- func (d *Driver) CancelToken(ctx context.Context, uploadSession *serializer.UploadSession) error
- func (d *Driver) Delete(ctx context.Context, files []string) ([]string, error)
- func (d *Driver) Get(ctx context.Context, path string) (response.RSCloser, error)
- func (d *Driver) List(ctx context.Context, path string, recursive bool) ([]response.Object, error)
- func (d *Driver) Put(ctx context.Context, file fsctx.FileHeader) error
- func (d *Driver) Source(ctx context.Context, path string, ttl int64, isDownload bool, speed int) (string, error)
- func (d *Driver) Thumb(ctx context.Context, file *model.File) (*response.ContentResponse, error)
- func (d *Driver) Token(ctx context.Context, ttl int64, uploadSession *serializer.UploadSession, ...) (*serializer.UploadCredential, error)
- type Endpoints
- type OAuthError
- type RespError
Constants ¶
View Source
const (
TokenCachePrefix = "googledrive_"
)
Variables ¶
View Source
var ( // Defualt required scopes RequiredScope = []string{ drive.DriveScope, "openid", "profile", "https://www.googleapis.com/auth/userinfo.profile", } // ErrInvalidRefreshToken 上传策略无有效的RefreshToken ErrInvalidRefreshToken = errors.New("no valid refresh token in this policy") )
Functions ¶
Types ¶
type Client ¶
type Client struct { Endpoints *Endpoints Policy *model.Policy Credential *Credential ClientID string ClientSecret string Redirect string Request request.Client ClusterController cluster.Controller }
Client Google Drive client
func (*Client) AccessToken ¶
func (*Client) ObtainToken ¶
func (client *Client) ObtainToken(ctx context.Context, code, refreshToken string) (*Credential, error)
ObtainToken 通过code或refresh_token兑换token
type Credential ¶
type Credential struct { ExpiresIn int64 `json:"expires_in"` Scope string `json:"scope"` AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` UserID string `json:"user_id"` }
Credential 获取token时返回的凭证
type Driver ¶
Driver Google Drive 适配器
func (*Driver) CancelToken ¶
func (d *Driver) CancelToken(ctx context.Context, uploadSession *serializer.UploadSession) error
func (*Driver) Token ¶
func (d *Driver) Token(ctx context.Context, ttl int64, uploadSession *serializer.UploadSession, file fsctx.FileHeader) (*serializer.UploadCredential, error)
type Endpoints ¶
type Endpoints struct { UserConsentEndpoint string // OAuth认证的基URL TokenEndpoint string // OAuth token 基URL EndpointURL string // 接口请求的基URL }
Endpoints OneDrive客户端相关设置
type OAuthError ¶
type OAuthError struct { ErrorType string `json:"error"` ErrorDescription string `json:"error_description"` }
OAuthError OAuth相关接口的错误响应
Click to show internal directories.
Click to hide internal directories.