MCPcopy Create free account
hub / github.com/plexdrive/plexdrive / NewClient

Function NewClient

drive/drive.go:45–78  ·  view source on GitHub ↗

NewClient creates a new Google Drive client

(config *config.Config, cache *Cache, refreshInterval time.Duration, rootNodeID string, driveID string)

Source from the content-addressed store, hash-verified

43
44// NewClient creates a new Google Drive client
45func NewClient(config *config.Config, cache *Cache, refreshInterval time.Duration, rootNodeID string, driveID string) (*Client, error) {
46 client := Client{
47 cache: cache,
48 context: context.Background(),
49 config: &oauth2.Config{
50 ClientID: config.ClientID,
51 ClientSecret: config.ClientSecret,
52 Endpoint: oauth2.Endpoint{
53 AuthURL: "https://accounts.google.com/o/oauth2/auth",
54 TokenURL: "https://accounts.google.com/o/oauth2/token",
55 },
56 RedirectURL: "urn:ietf:wg:oauth:2.0:oob",
57 Scopes: []string{gdrive.DriveScope},
58 },
59 rootNodeID: rootNodeID,
60 driveID: driveID,
61 ChangedObjects: make(chan []*APIObject, 1),
62 }
63
64 if "" == client.rootNodeID {
65 client.rootNodeID = "root"
66 }
67 if "" != client.driveID && client.rootNodeID == "root" {
68 client.rootNodeID = client.driveID
69 }
70
71 if err := client.authorize(); nil != err {
72 return nil, err
73 }
74
75 go client.startWatchChanges(refreshInterval)
76
77 return &client, nil
78}
79
80func (d *Client) startWatchChanges(refreshInterval time.Duration) {
81 d.checkChanges(true)

Callers 1

mainFunction · 0.92

Calls 2

authorizeMethod · 0.95
startWatchChangesMethod · 0.95

Tested by

no test coverage detected