Gdrive token.json without path #301

Closed
opened 2026-01-19 18:29:48 +00:00 by michael · 2 comments
Owner

Originally created by @jguidini on GitHub.

Hi, I tested provider local, mount a systemd Unit and all worked wonderful. Next step was test on GDrive, we are an educational institution and we have ilimited GDrive. On CLI all works very well, but changing the parameters to use systemd to manage service the things don't go well. After many tests using scritps, monit and systemd I got the problem source, the path of token.json is not configured on source code, by default de binary write to ./ (your same path), but when systemd ou monit call the binary the path is changed (i don't no how) and new autorization to the service is needed.

In file server/storage.go:

571 // Retrieve a token, saves the token, then returns the generated client.
572 func getGDriveClient(config *oauth2.Config) *http.Client {
573 tokenFile := "token.json"
574 tok, err := gDriveTokenFromFile(tokenFile)
575 if err != nil {
576 tok = getGDriveTokenFromWeb(config)
577 saveGDriveToken(tokenFile, tok)
578 }
579 return config.Client(context.Background(), tok)
580 }

We see the file without a path. I do this:

571 // Retrieve a token, saves the token, then returns the generated client.
572 func getGDriveClient(config *oauth2.Config) *http.Client {
573 //      tokenFile := "token.json"
574         tokenFile := "/opt/transfer.sh/conf/token.json"
575         tok, err := gDriveTokenFromFile(tokenFile)
576         if err != nil {
577                 tok = getGDriveTokenFromWeb(config)
578                 saveGDriveToken(tokenFile, tok)
579         }
580         return config.Client(context.Background(), tok)
581 }

And works! I tested on monit and will test on systemd. Obviosly /opt/transfer.sh/conf is my path, and is my --gdrive-local-config-path.

I'm not a programmer, but know a little.. i will try to do a patch to use --gdrive-local-config-path as path to token.json, but I can't garantee this.

Thanks!

Originally created by @jguidini on GitHub. Hi, I tested provider local, mount a systemd Unit and all worked wonderful. Next step was test on GDrive, we are an educational institution and we have ilimited GDrive. On CLI all works very well, but changing the parameters to use systemd to manage service the things don't go well. After many tests using scritps, monit and systemd I got the problem source, the path of token.json is not configured on source code, by default de binary write to ./ (your same path), but when systemd ou monit call the binary the path is changed (i don't no how) and new autorization to the service is needed. In file server/storage.go: 571 // Retrieve a token, saves the token, then returns the generated client. 572 func getGDriveClient(config *oauth2.Config) *http.Client { 573 tokenFile := "token.json" 574 tok, err := gDriveTokenFromFile(tokenFile) 575 if err != nil { 576 tok = getGDriveTokenFromWeb(config) 577 saveGDriveToken(tokenFile, tok) 578 } 579 return config.Client(context.Background(), tok) 580 } We see the file without a path. I do this: 571 // Retrieve a token, saves the token, then returns the generated client. 572 func getGDriveClient(config *oauth2.Config) *http.Client { 573 // tokenFile := "token.json" 574 tokenFile := "/opt/transfer.sh/conf/token.json" 575 tok, err := gDriveTokenFromFile(tokenFile) 576 if err != nil { 577 tok = getGDriveTokenFromWeb(config) 578 saveGDriveToken(tokenFile, tok) 579 } 580 return config.Client(context.Background(), tok) 581 } And works! I tested on monit and will test on systemd. Obviosly /opt/transfer.sh/conf is my path, and is my --gdrive-local-config-path. I'm not a programmer, but know a little.. i will try to do a patch to use --gdrive-local-config-path as path to token.json, but I can't garantee this. Thanks!
Author
Owner

@paolafrancesca commented on GitHub:

@jguidini you're right: fixed with #170

@paolafrancesca commented on GitHub: @jguidini you're right: fixed with #170
Author
Owner

@paolafrancesca commented on GitHub:

@jguidini just for reference: you can set RootDirectory and WorkingDir in systemd units to chdir the service to a given directory (https://www.freedesktop.org/software/systemd/man/systemd.exec.html)

@paolafrancesca commented on GitHub: @jguidini just for reference: you can set `RootDirectory` and `WorkingDir` in systemd units to chdir the service to a given directory (https://www.freedesktop.org/software/systemd/man/systemd.exec.html)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dutchcoders/transfer.sh#301