Rene Alas
Rene Alas

Reputation: 541

Is there a way to delete an entire Firebase Project with a Cloud Function

Just wondering if there is a way to set up a Cloud Function to delete the entire Firebase Project.

Basically like a Self Destruct scenario.

Kind Regards.

Upvotes: 0

Views: 125

Answers (1)

Marc Anthony B
Marc Anthony B

Reputation: 4069

As mentioned by @Frank, Resource Manager has method called Method: projects.delete.

Here's a guide on using it on postman:

  1. Open the Google Cloud Console.
  2. At the top-left, click Menu menu > APIs & Services > Credentials.
  3. Click Create credentials > OAuth Client ID.
  4. Select the appropriate application type for your project and enter any additional information required. For your use-case, choose Web Application. (If this is your first time creating a client ID, you can also configure your consent screen by clicking Consent Screen. The following procedure explains how to set up the Consent screen. You won't be prompted to configure the consent screen after you do it the first time.)
  5. For Authorized redirect URIs, click Add URI. Go back to Postman, copy the Callback URL from Postman as highlighted green on the image below and paste it on the Add URI textbox.enter image description here
  6. Click Create client ID.
  7. A dialog box named OAuth client created will pop up after creating Client ID as shown in the image. enter image description here
  8. Take note of Client ID and Client Secret. Click on the DOWNLOAD JSON. Securely save it somewhere safe.
  9. Open the JSON file you've saved. JSON file should look like this:
{
  "web": {
    "client_id": "xxxxxxx.apps.googleusercontent.com",
    "project_id": "xxxxxxxxx",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_secret": "xxxxx-xxxxxxxxxxxx-xxxxxx",
    "redirect_uris": [
      "https://oauth.pstmn.io/v1/browser-callback"
    ]
  }
}
  1. Back to Postman Authorization Tab, Configure New Token. enter image description here
  2. Fill out all information required:
    • Token Name: Any name you want.
    • Grant Type: Authorization Code.
    • Auth URL: "auth_uri" from JSON file.
    • Access Token URL: "token_uri" from JSON file.
    • Client ID: "client_id" from JSON file.
    • Client Secret: "client_secret" from JSON file.
    • Scope: "https://www.googleapis.com/auth/cloud-platform" (For Reference: Authorization Scopes)
    • Client Authentication: Send as Basic Auth header.
  3. Click Get New Access Token.
  4. Follow the prompt login on your screen. Your Access Token is now generated.
  5. Click Use Token.
  6. You should now be able to Send a DELETE request.

Upvotes: 1

Related Questions