Gdrive credential error #235

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

Originally created by @thanakijwanavit on GitHub.

I ran the code with following option go run main.go --gdrive-client-json-filepath ../credential/creden.json --gdrive-local-config-path /tmp/ --basedir /tmp/ --provider gdrive

However, it can't find the necessary oauth file which is really confusing. I downloaded the file for my service account on developers.google.com and it seems valid

Here is the response

panic: oauth2/google: no credentials found

goroutine 1 [running]:
github.com/dutchcoders/transfer.sh/cmd.New.func2(0x40000a9340)
        /transfer.sh/cmd/cmd.go:361 +0x1b84
github.com/urfave/cli.HandleAction(0x79e320, 0x400036b630, 0x40000a9340, 0x40000a9340, 0x0)
        /go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:525 +0x14c
github.com/urfave/cli.(*App).Run(0x400039a000, 0x4000020090, 0x9, 0x9, 0x0, 0x0)
        /go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:285 +0x41c
github.com/urfave/cli.(*App).RunAndExitOnError(0x400039a000)
        /go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:297 +0x58
main.main()
        /transfer.sh/main.go:7 +0x30
exit status 2

Here is the content of the file cat /credential/creden.json

{
  "type": "service_account",
  "project_id": "healtdhsryh",
  "private_key_id": "a045016c17d000d401e1d8uuyjhlkhlkhf588fad",
  "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC+N1SQrFKQ1GIR\n03I7GcT6NvfOZnUxbU0PYvin1vpyNnSrZkt7q7p94NNYZ0pvZWVdFh77wCqFnyQ+\nQwcV4k3PqR7WFK+No5iyQitlRx9aFwGmYP1CdY5lA7sFgYKBbpADbHiHU12nSIzl\n7TPdWs3FkBuXH2JLiINrlC2ao4b3XQT+EQY30s+M23wVZpe3SaDnG2Zmyzfl5ny3\nIwex7+Qn7yajoUO1q+mOZNTXzIt9VLY\n-----END PRIVATE KEY-----\n",
  "client_email": "transfersh-gdrive@healdfbsbf.iam.gserviceaccount.com",
  "client_id": "112844923881213577344",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/transfersh-gdrive%40healthexpress.iam.gserviceaccount.com"
} ```
Originally created by @thanakijwanavit on GitHub. I ran the code with following option ```go run main.go --gdrive-client-json-filepath ../credential/creden.json --gdrive-local-config-path /tmp/ --basedir /tmp/ --provider gdrive``` However, it can't find the necessary oauth file which is really confusing. I downloaded the file for my service account on developers.google.com and it seems valid Here is the response ``` panic: oauth2/google: no credentials found goroutine 1 [running]: github.com/dutchcoders/transfer.sh/cmd.New.func2(0x40000a9340) /transfer.sh/cmd/cmd.go:361 +0x1b84 github.com/urfave/cli.HandleAction(0x79e320, 0x400036b630, 0x40000a9340, 0x40000a9340, 0x0) /go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:525 +0x14c github.com/urfave/cli.(*App).Run(0x400039a000, 0x4000020090, 0x9, 0x9, 0x0, 0x0) /go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:285 +0x41c github.com/urfave/cli.(*App).RunAndExitOnError(0x400039a000) /go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:297 +0x58 main.main() /transfer.sh/main.go:7 +0x30 exit status 2 ```` Here is the content of the file ```cat /credential/creden.json``` ``` { "type": "service_account", "project_id": "healtdhsryh", "private_key_id": "a045016c17d000d401e1d8uuyjhlkhlkhf588fad", "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC+N1SQrFKQ1GIR\n03I7GcT6NvfOZnUxbU0PYvin1vpyNnSrZkt7q7p94NNYZ0pvZWVdFh77wCqFnyQ+\nQwcV4k3PqR7WFK+No5iyQitlRx9aFwGmYP1CdY5lA7sFgYKBbpADbHiHU12nSIzl\n7TPdWs3FkBuXH2JLiINrlC2ao4b3XQT+EQY30s+M23wVZpe3SaDnG2Zmyzfl5ny3\nIwex7+Qn7yajoUO1q+mOZNTXzIt9VLY\n-----END PRIVATE KEY-----\n", "client_email": "transfersh-gdrive@healdfbsbf.iam.gserviceaccount.com", "client_id": "112844923881213577344", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/transfersh-gdrive%40healthexpress.iam.gserviceaccount.com" } ```
Author
Owner

@paolafrancesca commented on GitHub:

did you solve the issue @thanakijwanavit ?
my client json file is like the following:

{"installed":{"client_id":"...","project_id":"...","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"...","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","..."]}}
@paolafrancesca commented on GitHub: did you solve the issue @thanakijwanavit ? my client json file is like the following: ``` {"installed":{"client_id":"...","project_id":"...","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"...","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","..."]}} ```
Author
Owner

@paolafrancesca commented on GitHub:

@thanakijwanavit you provided a service acount json instead of a client api key one
at https://console.developers.google.com/apis/credentials you can create a api key and download the json file to use with transfer.sh

first time you will run the service please do in an iteractive shell because you will be prompted with a url to visit to get the authorization code for the client. once setup you can ran the service and the related config will be saved in the --gdrive-local-config-path. I suggest you to not use /tmp since its contet will be probably lost upon reboot

also, it's not safe to share you service account data including the private key publicly, I suggest you to revoke that service account

please, let me know if you were able to run the service properly

@paolafrancesca commented on GitHub: @thanakijwanavit you provided a service acount json instead of a client api key one at https://console.developers.google.com/apis/credentials you can create a api key and download the json file to use with transfer.sh first time you will run the service please do in an iteractive shell because you will be prompted with a url to visit to get the authorization code for the client. once setup you can ran the service and the related config will be saved in the `--gdrive-local-config-path`. I suggest you to not use `/tmp` since its contet will be probably lost upon reboot also, it's not safe to share you service account data including the private key publicly, I suggest you to revoke that service account please, let me know if you were able to run the service properly
Author
Owner

@paolafrancesca commented on GitHub:

@thanakijwanavit I don't remember: anyway in my json it is ["urn:ietf:wg:oauth:2.0:oob","http://localhost"]

@paolafrancesca commented on GitHub: @thanakijwanavit I don't remember: anyway in my json it is `["urn:ietf:wg:oauth:2.0:oob","http://localhost"]`
Author
Owner

@thanakijwanavit commented on GitHub:

did you solve the issue @thanakijwanavit ?
my client json file is like the following:

{"installed":{"client_id":"...","project_id":"...","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"...","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","..."]}}

where did you get the redirect url from?

@thanakijwanavit commented on GitHub: > did you solve the issue @thanakijwanavit ? > my client json file is like the following: > > ``` > {"installed":{"client_id":"...","project_id":"...","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"...","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","..."]}} > ``` where did you get the redirect url from?
Author
Owner

@thanakijwanavit commented on GitHub:

Thanks so much for your reply
I have created a Oauth-client-id.json however I got the following error

panic: oauth2/google: missing redirect URL in the client_credentials.json

goroutine 1 [running]:
github.com/dutchcoders/transfer.sh/cmd.New.func2(0x40000a91e0)
        /transfer.sh/cmd/cmd.go:361 +0x1b84
github.com/urfave/cli.HandleAction(0x79e320, 0x400036b630, 0x40000a91e0, 0x40000a91e0, 0x0)
        /go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:525 +0x14c
github.com/urfave/cli.(*App).Run(0x4000398000, 0x40000201b0, 0x9, 0x9, 0x0, 0x0)
        /go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:285 +0x41c
github.com/urfave/cli.(*App).RunAndExitOnError(0x4000398000)
        /go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:297 +0x58
main.main()
        /transfer.sh/main.go:7 +0x30
exit status 2 

I am not sure if this is the correct json credential file but there seems to be no downloadable json file for api key

the current content of the creden.json file is

{"web":{"client_id":"........apps.googleusercontent.com","project_id":"....","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"....."}} 
@thanakijwanavit commented on GitHub: Thanks so much for your reply I have created a Oauth-client-id.json however I got the following error ``` panic: oauth2/google: missing redirect URL in the client_credentials.json goroutine 1 [running]: github.com/dutchcoders/transfer.sh/cmd.New.func2(0x40000a91e0) /transfer.sh/cmd/cmd.go:361 +0x1b84 github.com/urfave/cli.HandleAction(0x79e320, 0x400036b630, 0x40000a91e0, 0x40000a91e0, 0x0) /go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:525 +0x14c github.com/urfave/cli.(*App).Run(0x4000398000, 0x40000201b0, 0x9, 0x9, 0x0, 0x0) /go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:285 +0x41c github.com/urfave/cli.(*App).RunAndExitOnError(0x4000398000) /go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:297 +0x58 main.main() /transfer.sh/main.go:7 +0x30 exit status 2 ``` I am not sure if this is the correct json credential file but there seems to be no downloadable json file for api key the current content of the creden.json file is ``` {"web":{"client_id":"........apps.googleusercontent.com","project_id":"....","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"....."}} ```
Author
Owner

@thanakijwanavit commented on GitHub:

OK I will try that

@thanakijwanavit commented on GitHub: OK I will try that
Author
Owner

@paolafrancesca commented on GitHub:

@thanakijwanavit did it work?

@paolafrancesca commented on GitHub: @thanakijwanavit did it work?
Author
Owner

@thanakijwanavit commented on GitHub:

It works!!! thanks so much this is excellent. At the end I added some random uri and copied the [code] from the get query variable.

https://[some random uri]&state=state-token&code=[the code is here]&.......
@thanakijwanavit commented on GitHub: It works!!! thanks so much this is excellent. At the end I added some random uri and copied the [code] from the get query variable. ``` https://[some random uri]&state=state-token&code=[the code is here]&....... ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dutchcoders/transfer.sh#235