Skip to content
This repository has been archived by the owner on Sep 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #42 from hatboysam/env-vars
Browse files Browse the repository at this point in the history
Config using environment vars
  • Loading branch information
Burcu Dogan committed Dec 4, 2014
2 parents f63d922 + 8042ca4 commit bccefe4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `GOOGLE_API_CLIENT_ID` and `GOOGLE_API_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:

Expand Down
15 changes: 12 additions & 3 deletions init.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@

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("GOOGLE_API_CLIENT_ID")
g.context.ClientSecret = os.Getenv("GOOGLE_API_CLIENT_SECRET")
if g.context.ClientId == "" || g.context.ClientSecret == "" {
g.context.ClientId = "354790962074-7rrlnuanmamgg1i4feed12dpuq871bvd.apps.googleusercontent.com"
g.context.ClientSecret = "RHjKdah8RrHFwu6fcc0uEVCw"
}

if refresh, err = RetrieveRefreshToken(g.context); err != nil {
return
}
Expand Down

0 comments on commit bccefe4

Please sign in to comment.