-
Notifications
You must be signed in to change notification settings - Fork 554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
google-cloud-ruby does not work with Application Default Credentials #951
Comments
Thanks for the issue, @remi. I was not aware this was being discussed on the other language projects. In googleapis/google-cloud-node#1653 it seems like the consensus is that this functionality should be provided by the authentication library, and not the google-cloud-node library. For ruby, that is the googleauth gem. The googleauth gem does sniff for both the GCE environment, and the gcloud SDK Application Default Credentials. But when we asked them to support retrieving the default project_id for GCE they declined, saying that it was not something the library should provide. What is your opinion? Is this something that googleauth should provide, as it looks to be in future releases for python and node? Or something that google-cloud should provide? |
Because this feature is so tightly coupled to the Google Cloud SDK command-line tool, I think it makes sense for this feature to be implemented in google-cloud rather than the generalized Ruby Google API client. For Python, project ID detection is currently implemented in google-cloud-python, not pushed down into the general Python Google API client. I rather like Python's project detection:
Also, I see that googleauth sniffs the Google Compute Engine metadata server for an auth token, which is very relevant to auth, I think that it makes the most sense for google-cloud-ruby to lookup the project ID. What do you think? |
Follow-up comment: I have been discussing this offline with Python and Node.js stakeholders. The referenced Node.js issue also includes discussion about upcoming changes to the the Python Google Auth library to move project detection into the authentication library. Reasoning / benefits:
The benefits of putting this code into the Google Auth library for Ruby are great and will benefit all libraries that make use of googleauth I'll follow-up with an issue files on the googleauth library. We can block this pending support for project detection in googleauth? /cc @jonparrott @jmdobry |
Sounds good to me! We noticed that the newer keyfile JSON files also include the project_id. Since the google-cloud libs already provide googleauth with the JSON file I think it would be great if it gave back the project_id as well as the credentials object. |
This issue is blocked by googleapis/google-auth-library-ruby#90, so I am moving this issue to the feature backlog until we are unblocked. |
Still having the same issue with Ruby version 2.4.4 thanks |
The recently released |
I'm going to reclose this issue and open a new issue for the remaining work. |
See also: google-cloud-node does not work with Application Default Credentials
Problem
After running
gcloud beta auth application-default login
I should be able to use google-cloud-ruby to access Google Cloud Platform services, but I can't. I must set theGOOGLE_CLOUD_PROJECT
env var or explicitly pass a project ID to a client for google-cloud-ruby to work.Steps to Reproduce
gcloud init
, you'll be prompted to set a default projectgcloud beta auth application-default login
and follow the OAuth 2.0 flow to logingem install google-cloud-storage
to install a google-cloud-ruby client libraryirb
and use the google-cloud-storage gem to interact with Google Cloud Storage. In this case, I am following the example code snippet for Retrieving Buckets found on the website for google-cloud-ruby.Expected
After a user runs
gcloud beta auth application-default login
, google-cloud-ruby client libraries should work without explicitly setting a project ID via the code or an environment variable.The text was updated successfully, but these errors were encountered: