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

Commit bccefe4

Browse files
author
Burcu Dogan
committed
Merge pull request #42 from hatboysam/env-vars
Config using environment vars
2 parents f63d922 + 8042ca4 commit bccefe4

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Use `drive help` for further reference.
1717
$ drive diff [path] # outputs a diff of local and remote
1818
$ drive publish [path] # publishes a file, outputs URL
1919

20+
## Configuration
21+
22+
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
23+
2024
## Why another Google Drive client?
2125
Background sync is not just hard, it's stupid. My technical and philosophical rants about why it is not worth to implement:
2226

init.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,20 @@
1414

1515
package drive
1616

17+
import (
18+
"os"
19+
)
20+
1721
func (g *Commands) Init() (err error) {
1822
var refresh string
19-
// TODO: read from env variable.
20-
g.context.ClientId = "354790962074-7rrlnuanmamgg1i4feed12dpuq871bvd.apps.googleusercontent.com"
21-
g.context.ClientSecret = "RHjKdah8RrHFwu6fcc0uEVCw"
23+
24+
g.context.ClientId = os.Getenv("GOOGLE_API_CLIENT_ID")
25+
g.context.ClientSecret = os.Getenv("GOOGLE_API_CLIENT_SECRET")
26+
if g.context.ClientId == "" || g.context.ClientSecret == "" {
27+
g.context.ClientId = "354790962074-7rrlnuanmamgg1i4feed12dpuq871bvd.apps.googleusercontent.com"
28+
g.context.ClientSecret = "RHjKdah8RrHFwu6fcc0uEVCw"
29+
}
30+
2231
if refresh, err = RetrieveRefreshToken(g.context); err != nil {
2332
return
2433
}

0 commit comments

Comments
 (0)