diff --git a/README.md b/README.md index 94698312..37df1fcd 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ Use `drive help` for further reference. $ drive diff [path] # outputs a diff of local and remote $ drive publish [path] # publishes a file, outputs URL +## Configuration + +If you would like to use your own client ID/client secret pair with `drive`, set the `DRIVE_CLIENT_ID` and `DRIVE_CLIENT_SECRET` variables in your environment + ## Why another Google Drive client? Background sync is not just hard, it's stupid. My technical and philosophical rants about why it is not worth to implement: diff --git a/init.go b/init.go index c254fb66..ed4cb5e2 100644 --- a/init.go +++ b/init.go @@ -14,11 +14,23 @@ package drive +import ( + "os" +) + func (g *Commands) Init() (err error) { var refresh string - // TODO: read from env variable. - g.context.ClientId = "354790962074-7rrlnuanmamgg1i4feed12dpuq871bvd.apps.googleusercontent.com" - g.context.ClientSecret = "RHjKdah8RrHFwu6fcc0uEVCw" + + g.context.ClientId = os.Getenv("DRIVE_CLIENT_ID") + if g.context.ClientId == "" { + g.context.ClientId = "354790962074-7rrlnuanmamgg1i4feed12dpuq871bvd.apps.googleusercontent.com" + } + + g.context.ClientSecret = os.Getenv("DRIVE_CLIENT_SECRET") + if g.context.ClientSecret == "" { + g.context.ClientSecret = "RHjKdah8RrHFwu6fcc0uEVCw" + } + if refresh, err = RetrieveRefreshToken(g.context); err != nil { return }