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

Use GOOGLE_API_CLIENT_ID and GOOGLE_API_CLIENT_SECRET #35

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Use `drive help` for further reference.
$ drive diff [path] # outputs a diff of local and remote
$ drive publish [path] # publishes a file, outputs URL

To use your own Google Drive API credentials instead of the built-in credentials, set `GOOGLE_API_CLIENT_ID` and `GOOGLE_API_CLIENT_SECRET` appropriately in your environment before running `drive init`. See [the Google API docs](https://developers.google.com/drive/web/quickstart/quickstart-go#step_1_enable_the_drive_api) for more information.

## 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
18 changes: 15 additions & 3 deletions init.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,23 @@

package drive

import "os"

const (
clientIDEnvKey = "GOOGLE_API_CLIENT_ID"
clientSecretEnvKey = "GOOGLE_API_CLIENT_SECRET"
)

func (g *Commands) Init() (err error) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func (g *Commands) Init() 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(clientIDEnvKey)
g.context.ClientSecret = os.Getenv(clientSecretEnvKey)
if len(g.context.ClientId) == 0 || len(g.context.ClientSecret) == 0 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g.context.ClientID == "" || g.context.C

g.context.ClientId = "354790962074-7rrlnuanmamgg1i4feed12dpuq871bvd.apps.googleusercontent.com"
g.context.ClientSecret = "RHjKdah8RrHFwu6fcc0uEVCw"
}

if refresh, err = RetrieveRefreshToken(g.context); err != nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

return
}
Expand Down