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

Remove Credentials from Source. Add Shared Drive Usage. #659

Open
wants to merge 20 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 7 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GOARCH: "386"
GOOS: linux
EXTRA_FILES: "LICENSE"
Expand All @@ -23,7 +23,7 @@ jobs:
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GOARCH: amd64
GOOS: linux
EXTRA_FILES: "LICENSE"
Expand All @@ -35,7 +35,7 @@ jobs:
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GOARCH: "arm"
GOOS: linux
EXTRA_FILES: "LICENSE"
Expand All @@ -47,7 +47,7 @@ jobs:
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GOARCH: arm64
GOOS: linux
EXTRA_FILES: "LICENSE"
Expand All @@ -59,7 +59,7 @@ jobs:
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GOARCH: amd64
GOOS: darwin
EXTRA_FILES: "LICENSE"
Expand All @@ -71,7 +71,7 @@ jobs:
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GOARCH: "386"
GOOS: windows
EXTRA_FILES: "LICENSE"
Expand All @@ -83,7 +83,7 @@ jobs:
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GOARCH: amd64
GOOS: windows
EXTRA_FILES: "LICENSE"
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.

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ gdrive
gdrive is a command line utility for interacting with Google Drive.

## News

#### 11.11.2022
Because this repo didnot update, You can use this [Repo](https://github.com/Msameim181/gdrive-cli-builder) to build and use gdrive.

#### 28.05.2021
gdrive is finally verified for using sensitive scopes which should fix the `This app is blocked` error. Note that the project name will show up as `project-367116221053` when granting access to you account. (I don't dare to change any more settings in the google console.)

Expand All @@ -20,7 +24,7 @@ Version 1.5 or higher.
brew install gdrive
```
### Other
Download `gdrive` from one of the [links in the latest release](https://github.com/prasmussen/gdrive/releases).
Download `gdrive` from one of the [links in the latest release](https://github.com/Msameim181/gdrive/releases).
The first time gdrive is launched (i.e. run `gdrive about` in your
terminal not just `gdrive`), you will be prompted for a verification code.
The code is obtained by following the printed url and authenticating with the
Expand All @@ -34,7 +38,7 @@ 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/Msameim181/gdrive
```
The gdrive binary should now be available at `$GOPATH/bin/gdrive`

Expand Down
2 changes: 1 addition & 1 deletion auth/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func getConfig(clientId, clientSecret string) *oauth2.Config {
ClientID: clientId,
ClientSecret: clientSecret,
Scopes: []string{"https://www.googleapis.com/auth/drive"},
RedirectURL: "urn:ietf:wg:oauth:2.0:oob",
RedirectURL: "http://localhost/",
Endpoint: oauth2.Endpoint{
AuthURL: "https://accounts.google.com/o/oauth2/auth",
TokenURL: "https://accounts.google.com/o/oauth2/token",
Expand Down
2 changes: 1 addition & 1 deletion compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

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

Expand Down
7 changes: 4 additions & 3 deletions drive/changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package drive

import (
"fmt"
"google.golang.org/api/drive/v3"
"io"
"text/tabwriter"

"google.golang.org/api/drive/v3"
)

type ListChangesArgs struct {
Expand All @@ -27,7 +28,7 @@ func (self *Drive) ListChanges(args ListChangesArgs) error {
return nil
}

changeList, err := self.service.Changes.List(args.PageToken).PageSize(args.MaxChanges).RestrictToMyDrive(true).Fields("newStartPageToken", "nextPageToken", "changes(fileId,removed,time,file(id,name,md5Checksum,mimeType,createdTime,modifiedTime))").Do()
changeList, err := self.service.Changes.List(args.PageToken).PageSize(args.MaxChanges).RestrictToMyDrive(true).Fields("newStartPageToken", "nextPageToken", "changes(fileId,removed,time,file(id,name,md5Checksum,mimeType,createdTime,modifiedTime))").SupportsAllDrives(true).Do()
if err != nil {
return fmt.Errorf("Failed listing changes: %s", err)
}
Expand All @@ -43,7 +44,7 @@ func (self *Drive) ListChanges(args ListChangesArgs) error {
}

func (self *Drive) GetChangesStartPageToken() (string, error) {
res, err := self.service.Changes.GetStartPageToken().Do()
res, err := self.service.Changes.GetStartPageToken().SupportsAllDrives(true).Do()
if err != nil {
return "", fmt.Errorf("Failed getting start page token: %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions drive/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type DeleteArgs struct {
}

func (self *Drive) Delete(args DeleteArgs) error {
f, err := self.service.Files.Get(args.Id).Fields("name", "mimeType").Do()
f, err := self.service.Files.Get(args.Id).Fields("name", "mimeType").SupportsAllDrives(true).Do()
if err != nil {
return fmt.Errorf("Failed to get file: %s", err)
}
Expand All @@ -21,7 +21,7 @@ func (self *Drive) Delete(args DeleteArgs) error {
return fmt.Errorf("'%s' is a directory, use the 'recursive' flag to delete directories", f.Name)
}

err = self.service.Files.Delete(args.Id).Do()
err = self.service.Files.Delete(args.Id).SupportsAllDrives(true).Do()
if err != nil {
return fmt.Errorf("Failed to delete file: %s", err)
}
Expand All @@ -31,7 +31,7 @@ func (self *Drive) Delete(args DeleteArgs) error {
}

func (self *Drive) deleteFile(fileId string) error {
err := self.service.Files.Delete(fileId).Do()
err := self.service.Files.Delete(fileId).SupportsAllDrives(true).Do()
if err != nil {
return fmt.Errorf("Failed to delete file: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions drive/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (self *Drive) Download(args DownloadArgs) error {
return self.downloadRecursive(args)
}

f, err := self.service.Files.Get(args.Id).Fields("id", "name", "size", "mimeType", "md5Checksum").Do()
f, err := self.service.Files.Get(args.Id).Fields("id", "name", "size", "mimeType", "md5Checksum").SupportsAllDrives(true).Do()
if err != nil {
return fmt.Errorf("Failed to get file: %s", err)
}
Expand Down Expand Up @@ -108,7 +108,7 @@ func (self *Drive) DownloadQuery(args DownloadQueryArgs) error {
}

func (self *Drive) downloadRecursive(args DownloadArgs) error {
f, err := self.service.Files.Get(args.Id).Fields("id", "name", "size", "mimeType", "md5Checksum").Do()
f, err := self.service.Files.Get(args.Id).Fields("id", "name", "size", "mimeType", "md5Checksum").SupportsAllDrives(true).Do()
if err != nil {
return fmt.Errorf("Failed to get file: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion drive/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type ExportArgs struct {
}

func (self *Drive) Export(args ExportArgs) error {
f, err := self.service.Files.Get(args.Id).Fields("name", "mimeType").Do()
f, err := self.service.Files.Get(args.Id).Fields("name", "mimeType").SupportsAllDrives(true).Do()
if err != nil {
return fmt.Errorf("Failed to get file: %s", err)
}
Expand Down
5 changes: 3 additions & 2 deletions drive/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package drive

import (
"fmt"
"google.golang.org/api/drive/v3"
"io"

"google.golang.org/api/drive/v3"
)

type FileInfoArgs struct {
Expand All @@ -13,7 +14,7 @@ type FileInfoArgs struct {
}

func (self *Drive) Info(args FileInfoArgs) error {
f, err := self.service.Files.Get(args.Id).Fields("id", "name", "size", "createdTime", "modifiedTime", "md5Checksum", "mimeType", "parents", "shared", "description", "webContentLink", "webViewLink").Do()
f, err := self.service.Files.Get(args.Id).Fields("id", "name", "size", "createdTime", "modifiedTime", "md5Checksum", "mimeType", "parents", "shared", "description", "webContentLink", "webViewLink").SupportsAllDrives(true).Do()
if err != nil {
return fmt.Errorf("Failed to get file: %s", err)
}
Expand Down
7 changes: 4 additions & 3 deletions drive/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package drive

import (
"fmt"
"io"
"text/tabwriter"

"golang.org/x/net/context"
"google.golang.org/api/drive/v3"
"google.golang.org/api/googleapi"
"io"
"text/tabwriter"
)

type ListFilesArgs struct {
Expand Down Expand Up @@ -74,7 +75,7 @@ func (self *Drive) listAllFiles(args listAllFilesArgs) ([]*drive.File, error) {

controlledStop := fmt.Errorf("Controlled stop")

err := self.service.Files.List().Q(args.query).Fields(args.fields...).OrderBy(args.sortOrder).PageSize(pageSize).Pages(context.TODO(), func(fl *drive.FileList) error {
err := self.service.Files.List().Q(args.query).Fields(args.fields...).OrderBy(args.sortOrder).SupportsAllDrives(true).PageSize(pageSize).Pages(context.TODO(), func(fl *drive.FileList) error {
files = append(files, fl.Files...)

// Stop when we have all the files we need
Expand Down
5 changes: 3 additions & 2 deletions drive/mkdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package drive

import (
"fmt"
"google.golang.org/api/drive/v3"
"io"

"google.golang.org/api/drive/v3"
)

const DirectoryMimeType = "application/vnd.google-apps.folder"
Expand Down Expand Up @@ -35,7 +36,7 @@ func (self *Drive) mkdir(args MkdirArgs) (*drive.File, error) {
dstFile.Parents = args.Parents

// Create directory
f, err := self.service.Files.Create(dstFile).Do()
f, err := self.service.Files.Create(dstFile).SupportsAllDrives(true).Do()
if err != nil {
return nil, fmt.Errorf("Failed to create directory: %s", err)
}
Expand Down
5 changes: 3 additions & 2 deletions drive/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package drive

import (
"fmt"
"google.golang.org/api/drive/v3"
"path/filepath"

"google.golang.org/api/drive/v3"
)

func (self *Drive) newPathfinder() *remotePathfinder {
Expand Down Expand Up @@ -53,7 +54,7 @@ func (self *remotePathfinder) getParent(id string) (*drive.File, error) {
}

// Fetch file from drive
f, err := self.service.Get(id).Fields("id", "name", "parents").Do()
f, err := self.service.Get(id).Fields("id", "name", "parents").SupportsAllDrives(true).Do()
if err != nil {
return nil, fmt.Errorf("Failed to get file: %s", err)
}
Expand Down
5 changes: 3 additions & 2 deletions drive/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package drive

import (
"fmt"
"google.golang.org/api/drive/v3"
"io"
"text/tabwriter"

"google.golang.org/api/drive/v3"
)

type ShareArgs struct {
Expand All @@ -26,7 +27,7 @@ func (self *Drive) Share(args ShareArgs) error {
Domain: args.Domain,
}

_, err := self.service.Permissions.Create(args.FileId, permission).Do()
_, err := self.service.Permissions.Create(args.FileId, permission).SupportsAllDrives(true).Do()
if err != nil {
return fmt.Errorf("Failed to share file: %s", err)
}
Expand Down
11 changes: 6 additions & 5 deletions drive/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package drive

import (
"fmt"
"github.com/sabhiram/go-gitignore"
"github.com/soniakeys/graph"
"google.golang.org/api/drive/v3"
"google.golang.org/api/googleapi"
"io"
"os"
"path/filepath"
"strings"
"text/tabwriter"
"time"

ignore "github.com/sabhiram/go-gitignore"
"github.com/soniakeys/graph"
"google.golang.org/api/drive/v3"
"google.golang.org/api/googleapi"
)

const DefaultIgnoreFile = ".gdriveignore"
Expand Down Expand Up @@ -86,7 +87,7 @@ func (self *Drive) prepareSyncFiles(localPath string, root *drive.File, cmp File
}

func (self *Drive) isSyncFile(id string) (bool, error) {
f, err := self.service.Files.Get(id).Fields("appProperties").Do()
f, err := self.service.Files.Get(id).Fields("appProperties").SupportsAllDrives(true).Do()
if err != nil {
return false, fmt.Errorf("Failed to get file: %s", err)
}
Expand Down
7 changes: 4 additions & 3 deletions drive/sync_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package drive
import (
"bytes"
"fmt"
"google.golang.org/api/drive/v3"
"google.golang.org/api/googleapi"
"io"
"os"
"path/filepath"
"sort"
"time"

"google.golang.org/api/drive/v3"
"google.golang.org/api/googleapi"
)

type DownloadSyncArgs struct {
Expand Down Expand Up @@ -85,7 +86,7 @@ func (self *Drive) DownloadSync(args DownloadSyncArgs) error {

func (self *Drive) getSyncRoot(rootId string) (*drive.File, error) {
fields := []googleapi.Field{"id", "name", "mimeType", "appProperties"}
f, err := self.service.Files.Get(rootId).Fields(fields...).Do()
f, err := self.service.Files.Get(rootId).Fields(fields...).SupportsAllDrives(true).Do()
if err != nil {
return nil, fmt.Errorf("Failed to find root dir: %s", err)
}
Expand Down
Loading