google / oauth2l

oauth2l ("oauth tool") is a simple CLI for interacting with Google API authentication.
Apache License 2.0
643 stars 81 forks source link

Unable to get interactive auth flow from "oauth2 fetch --type=oauth" #86

Closed ahmetb closed 4 years ago

ahmetb commented 4 years ago

Hi, thanks for this cool tool!

I'm trying to see if I can build a command-line tool that authenticates to Google APIs using the auth model used by gcloud, which involves user to click to a browser URL and go to a localhost:8080 callback url, or something like user copying the token back to the CLI tool.

I've been trying to see if oauth2l can provide interactive input (#61 claims it can). But when I try this, it doesn't work:

$ oauth2l fetch --type=oauth --scope cloud-platform
google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

I'm curious if there's a code sample in this repo about that.

andyrzhao commented 4 years ago

Hi ahmetb, the issue is that you have not configured any local credentials. You can specify it through the "--credentials" parameter OR set an environment variable. Please refer to the README file, which includes instructions on how to download a credentials file from cloud console and example code. Note that in order to get an interactive auth flow (a.k.a 3-legged OAuth), you need to use an OAuth Client ID instead of service account key as your credentials.

ahmetb commented 4 years ago

Got it, thanks. My eyes were looking for -client-id , -client-secret options. This explains it.