<pre><code>from googleapiclient import discovery
from oauth2client.client import OAuth2Credentials as creds
crm = discovery.build(
 'cloudresourcemanager', 'v3', 
  http=creds.authorize(httplib2.Http()))

project = crm.projects().get(name=&quot;projects/&quot;+projectId).execute()
project_name = project['displayName']
</code></pre>

CC BY-SA 4.0
2022-10-25T03:06:23.777Z
2022-10-25T03:06:23.777Z
lisa_rao007
<p>Using cloud function - trying to make get call to get the project name and with the id - <a href="https://cloud.google.com/resource-manager/docs/creating-managing-projects#listing_projects" rel="nofollow noreferrer">https://cloud.google.com/resource-manager/docs/creating-managing-projects#listing_projects</a></p>
<pre><code> from googleapiclient import discovery
 from oauth2client.client import OAuth2Credentials as creds
 crm = discovery.build(
     'cloudresourcemanager', 'v3', 
      http=creds.authorize(httplib2.Http()))

 project = crm.projects().get(name=&quot;projects/&quot;+projectId).execute()
</code></pre>
<p>`</p>

CC BY-SA 4.0
2022-10-21T01:57:36.990Z
The link you put in your question has example Python code. What is the problem?
John Hanley
CC BY-SA 4.0
2022-10-21T02:06:23.093Z
@JohnHanley - If I have a project id - prj-mmm-test-11234 and how can I get the name for the id. That's what I am looking for, the code is just giving me the get project.
lisa_rao007
CC BY-SA 4.0
2022-10-21T02:18:42.327Z
Again what is the problem? You are using the correct code to get the project details. The member `name` is the Project Name.
John Hanley
CC BY-SA 4.0
2022-10-21T02:26:31.397Z
@JohnHanley - what is projectId. Because I want to give the value for project id and i want to get the name for that project id. Not all the project name, only the given project id
lisa_rao007
CC BY-SA 4.0
2022-10-21T03:23:36.193Z
@user3713336 your code is correct, if you have your project_id in projectId variable, this code will execute (given the auth goes through) and will store the [Project](https://cloud.google.com/resource-manager/reference/rest/v3/projects#Project) instance into the project variable. If this doesn't work for you, tell us what exactly doesn't work, what the error is or any details that you think could help
jabbson
CC BY-SA 4.0
2022-10-21T18:48:46.873Z
I figured it out = project_name = project['displayName']
lisa_rao007
<python><google-cloud-platform><cloud>
How to get gcp project name by project id
lisa_rao007
# How to get gcp project name by project id

(Asked by: username_0 on 2022-10-21)

Using cloud function - trying to make get call to get the project name and with the id - https://cloud.google.com/resource-manager/docs/creating-managing-projects#listing_projects
 from googleapiclient import discovery
 from oauth2client.client import OAuth2Credentials as creds
 crm = discovery.build(
     'cloudresourcemanager', 'v3', 
      http=creds.authorize(httplib2.Http()))

 project = crm.projects().get(name="projects/"+projectId).execute()

`

**Tags:** python, google-cloud-platform, cloud

> **Comments:**
> **username_1**: The link you put in your question has example Python code. What is the problem?  
> **username_0**: @JohnHanley - If I have a project id - prj-mmm-test-11234 and how can I get the name for the id. That's what I am looking for, the code is just giving me the get project.  
> **username_1**: Again what is the problem? You are using the correct code to get the project details. The member `name` is the Project Name.  
> **username_0**: @JohnHanley - what is projectId. Because I want to give the value for project id and i want to get the name for that project id. Not all the project name, only the given project id  
> **username_2**: @user3713336 your code is correct, if you have your project_id in projectId variable, this code will execute (given the auth goes through) and will store the [Project](https://cloud.google.com/resource-manager/reference/rest/v3/projects#Project) instance into the project variable. If this doesn't work for you, tell us what exactly doesn't work, what the error is or any details that you think could help  
> **username_0**: I figured it out = project_name = project['displayName']  

---

## 1 answers

### Answer by username_0 on 2022-10-25. Score: 1 | Accepted answer

from googleapiclient import discovery
from oauth2client.client import OAuth2Credentials as creds
crm = discovery.build(
 'cloudresourcemanager', 'v3', 
  http=creds.authorize(httplib2.Http()))

project = crm.projects().get(name="projects/"+projectId).execute()
project_name = project['displayName']


---

