This article shows how to display a list of Google Cloud Projects that you have access to list. This article includes two examples in Python that use two different Google Cloud Python libraries. These examples produce the same output as the Google CLI gcloud projects list command.

You can only list projects for which you have permissions to access. This means that you cannot see all projects unless you have the rights to access them. In my examples below I show which scopes are required. This also means that you can list projects across accounts. This allows you to see which projects you have access to using the credentials specified in the examples. I show how to use Application Default Credentials (ADC) and Service Account Credentials (Json file format).

These examples have been tested with Python 3.6 on Windows 10 Professional.

Example 1 using the Python Client Library (services discovery method):

Example 2 using the Python Google Cloud Resource Manager API Client Library: