How to get project id in Google Cloud Storage

google-cloud-storage, java

Solution

You should be able to see it in the Developer Console. Click on a project, and at the top it will tell you the project ID.

(If you were looking for a way of getting this programmatically, please clarify this in your question - it's not clear what information you "have in your hand" when you want to get the project ID... or whether you're expecting your users to create their own projects.)

Problem

I have activated Google Cloud Storage on my Gmail account, then created a new Project. As far as I see, and read from tutorials (https://developers.google.com/storage/docs/json_api/v1/json-api-java-samples), Client Secrets (client_secrets.json) are related to Projects, not to my account. Now, while using Java API, there is a way to receive the list of buckets, https://developers.google.com/storage/docs/json_api/v1/buckets/list Though it asks me to enter the project identifier as parameter. I checked API documentation, the download client secrets file (client_secrets.json), and Java methods, though nothing is providing me the "Project Identifier" that is related to authenticated client secret's project. Is there any method to find out on which project I am actively authenticated? I wouldn't want programme user to remember each project's identifier every time they authenticate in Java programme. The client secrets file is already related to a single project. Extra Information: Currently I developed a GUI Java application. By using Open File Dialog, user selects the downloaded "client_secrets.json" file. Then I use that example provided "authorise" method to get `Credentials` and `Storage` objects. After this, I want to list all buckets those are available in current project programmatically. (Current Project = The client_secrets.json is downloaded from a specific project.). But API requires me to enter the project name which doesn't seem to get programmatically.

Original source