Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2022-10-25T03:06:23.777Z
Answers: 2022-10-25T03:06:23.777Z
Answers: lisa_rao007
Body: <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>
  
Comments: CC BY-SA 4.0
Comments: 2022-10-21T01:57:36.990Z
Comments: The link you put in your question has example Python code. What is the problem?
Comments: John Hanley
Comments: CC BY-SA 4.0
Comments: 2022-10-21T02:06:23.093Z
Comments: @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.
Comments: lisa_rao007
Comments: CC BY-SA 4.0
Comments: 2022-10-21T02:18:42.327Z
Comments: Again what is the problem? You are using the correct code to get the project details. The member `name` is the Project Name.
Comments: John Hanley
Comments: CC BY-SA 4.0
Comments: 2022-10-21T02:26:31.397Z
Comments: @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
Comments: lisa_rao007
Comments: CC BY-SA 4.0
Comments: 2022-10-21T03:23:36.193Z
Comments: @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
Comments: jabbson
Comments: CC BY-SA 4.0
Comments: 2022-10-21T18:48:46.873Z
Comments: I figured it out = project_name = project['displayName']
Comments: lisa_rao007
Tags: <python><google-cloud-platform><cloud>
Title: How to get gcp project name by project id
UserDisplayName: lisa_rao007
ThreadText: # 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**: @username_1 - 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**: @username_1 - 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']
  
  ```
  
  
  ---
  
  