Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

improved naming #475

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: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ You will be prompted for a new verification code if the folder does not exist.

## Compile from source
```bash
go get github.com/prasmussen/gdrive
go get github.com/sabhiram/go-git-ignore
go get github.com/soniakeys/graph
go get -u google.golang.org/api/drive/v3
go get -u golang.org/x/oauth2/google
go get github.com/gdrive-org/gdrive
```
The gdrive binary should now be available at `$GOPATH/bin/gdrive`

Expand Down
3 changes: 2 additions & 1 deletion compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package main

import (
"encoding/json"
"github.com/prasmussen/gdrive/drive"
"os"

"./drive"
)

const MinCacheFileSize = 5 * 1024 * 1024
Expand Down
2 changes: 1 addition & 1 deletion gdrive.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/prasmussen/gdrive/cli"
"./cli"
)

const Name = "gdrive"
Expand Down
36 changes: 30 additions & 6 deletions handlers_drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import (
"path/filepath"
"time"

"github.com/prasmussen/gdrive/auth"
"github.com/prasmussen/gdrive/cli"
"github.com/prasmussen/gdrive/drive"
"golang.org/x/oauth2/google"
gd "google.golang.org/api/drive/v3"

"./auth"
"./cli"
"./drive"
)

const ClientId = "367116221053-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com"
const ClientSecret = "1qsNodXNaWq1mQuBjUjmvhoO"
var ClientId = "367116221053-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com"
var ClientSecret = "1qsNodXNaWq1mQuBjUjmvhoO"
const TokenFilename = "token_v2.json"
const DefaultCacheFileName = "file_cache.json"

Expand Down Expand Up @@ -341,6 +344,26 @@ func aboutExportHandler(ctx cli.Context) {
}

func getOauthClient(args cli.Arguments) (*http.Client, error) {
configDir := getConfigDir(args)

// IF there exists .gdrive/credentials.json, use it.
// Otherwise fall back to our default hardcoded project
b, err := ioutil.ReadFile(ConfigFilePath(configDir, "credentials.json"))
if err == nil {
gconfig,err := google.ConfigFromJSON(b, gd.DriveMetadataReadonlyScope)

// If above is present, ideally we could just use
// gconfig.Client(context.Background(), token
// see https://developers.google.com/drive/api/v3/quickstart/go
// but that will have to be in future version of the code
if err == nil {
ClientId = gconfig.ClientID
ClientSecret = gconfig.ClientSecret
}

}


if args.String("refreshToken") != "" && args.String("accessToken") != "" {
ExitF("Access token not needed when refresh token is provided")
}
Expand All @@ -353,7 +376,6 @@ func getOauthClient(args cli.Arguments) (*http.Client, error) {
return auth.NewAccessTokenClient(ClientId, ClientSecret, args.String("accessToken")), nil
}

configDir := getConfigDir(args)

if args.String("serviceAccount") != "" {
serviceAccountPath := ConfigFilePath(configDir, args.String("serviceAccount"))
Expand All @@ -365,6 +387,8 @@ func getOauthClient(args cli.Arguments) (*http.Client, error) {
}

tokenPath := ConfigFilePath(configDir, TokenFilename)

//println("Debug: using clientid=\n", ClientId);
return auth.NewFileSourceClient(ClientId, ClientSecret, tokenPath, authCodePrompt)
}

Expand Down
2 changes: 1 addition & 1 deletion handlers_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"github.com/prasmussen/gdrive/cli"
"./cli"
"os"
"runtime"
"strings"
Expand Down
28 changes: 0 additions & 28 deletions vendor/github.com/sabhiram/go-git-ignore/.gitignore

This file was deleted.

18 changes: 0 additions & 18 deletions vendor/github.com/sabhiram/go-git-ignore/.travis.yml

This file was deleted.

22 changes: 0 additions & 22 deletions vendor/github.com/sabhiram/go-git-ignore/LICENSE

This file was deleted.

17 changes: 0 additions & 17 deletions vendor/github.com/sabhiram/go-git-ignore/README.md

This file was deleted.

Loading