firebase / firebase-tools

The Firebase Command Line Tools
MIT License
3.98k stars 918 forks source link

Mobile SDK API has not been used in project #6310

Open yellowhat opened 11 months ago

yellowhat commented 11 months ago

[REQUIRED] Environment info

firebase-tools: 12.5.1

Platform: Ubuntu

[REQUIRED] Test case

Hi, after adding the googlecloud/firestore-semantic-search@0.1.6 to our extensions:

  "extensions": {
    "firestore-send-email": "firebase/firestore-send-email@0.1.26",
    "mailchimp-firebase-sync": "mailchimp/mailchimp-firebase-sync@0.5.2",
    "firestore-semantic-search": "googlecloud/firestore-semantic-search@0.1.6"
  }

we are not able to deploy extensions anymore via GitHub actions using a GCP Service Account key to authenticate:

      - name: Decode Google Cloud Service Account key
        env:
          GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
        run: |
          echo "$GCP_SA_KEY" | base64 -d > /tmp/creds.json
          echo "GOOGLE_APPLICATION_CREDENTIALS=/tmp/creds.json" >>"$GITHUB_ENV"

      - name: Deploy Firebase - functions
        run: |
          echo \"N\n\" | firebase deploy --only functions --interactive

      - name: Deploy Firebase except hosting
        run: |
          firebase deploy \
              --except functions,hosting \
              --project "$GOOGLE_CLOUD_PROJECT" \
              --debug

we get the following error:

Error when checking App Developer TOS for xxx. This is expected if authenticated via a service account: FirebaseError: HTTP Error: 403, Firebase Extensions Terms of Service Private API has not been used in project xxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/firebaseextensionstos-pa.googleapis.com/overview?project=xxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

...

Error: HTTP Error: 403, Mobile SDK API has not been used in project xxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/mobilesdk-pa.googleapis.com/overview?project=xxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
[2023-08-24T07:51:19.965Z] Error Context: {
  "body": {
    "error": {
      "code": 403,
      "message": "Mobile SDK API has not been used in project xxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/mobilesdk-pa.googleapis.com/overview?project=xxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
      "status": "PERMISSION_DENIED",
      "details": [
        {
          "@type": "type.googleapis.com/google.rpc.Help",
          "links": [
            {
              "description": "Google developers console API activation",
              "url": "https://console.developers.google.com/apis/api/mobilesdk-pa.googleapis.com/overview?project=xxx"
            }
          ]
        },
        {
          "@type": "type.googleapis.com/google.rpc.ErrorInfo",
          "reason": "SERVICE_DISABLED",
          "domain": "googleapis.com",
          "metadata": {
            "consumer": "projects/xxx",
            "service": "mobilesdk-pa.googleapis.com"
          }
        }
      ]
    }
  },
  "response": {
    "statusCode": 403
  }
}

The project number matches the real project.

Additional info:

$ firebase deploy --only extensions --debug
...
? Do you accept the Firebase Extensions User Terms of Service? (Y/n) 

Running CI after the extension has been deployed leads to the same error

Any suggestions?

Thanks

[REQUIRED] Steps to reproduce

export GOOGLE_APPLICATION_CREDENTIALS=<path_to_json>
firebase deploy --only extensions

[REQUIRED] Expected behavior

Extensions deployed

[REQUIRED] Actual behavior

Error above

yellowhat commented 10 months ago

I have done other tests using export GOOGLE_APPLICATION_CREDENTIALS=<path_to_json>.

firestore-semantic-search

From fresh firebase project, first:

$ cat firebase.json
{
  "extensions": {
    "firestore-semantic-search": "googlecloud/firestore-semantic-search@0.1.7"
  }
}

$ firebase deploy --only extensions --project "$GOOGLE_CLOUD_PROJECT"
...
✔  Deploy complete!

then:

$ cat firebase.json
{
  "extensions": {
    "firestore-send-email": "firebase/firestore-send-email@0.1.26",
    "mailchimp-firebase-sync": "mailchimp/mailchimp-firebase-sync@0.5.2",
    "firestore-semantic-search": "googlecloud/firestore-semantic-search@0.1.7"
  }
}

$ firebase deploy --only extensions --project "$GOOGLE_CLOUD_PROJECT"
i  extensions: By installing an extension instance onto a Firebase project, you accept the Firebase Extensions User Terms of Service: https://firebase.google.com/terms/extensions/user

Error: HTTP Error: 403, Mobile SDK API has not been used in project 339893162765 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/mobilesdk-pa.googleapis.com/overview?project=339893162765 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
i  extensions: Verifying secret params for firestore-send-email
(node:573) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(Use `node --trace-warnings ...` to show where the warning was created)

mailchimp-firebase-sync

From fresh firebase project, first:

$ cat firebase.json
{
  "extensions": {
    "mailchimp-firebase-sync": "mailchimp/mailchimp-firebase-sync@0.5.2"
  }
}

$ firebase deploy --only extensions --project "$GOOGLE_CLOUD_PROJECT"
...
✔  Deploy complete!

then:

$ cat firebase.json
{
  "extensions": {
    "firestore-send-email": "firebase/firestore-send-email@0.1.26",
    "mailchimp-firebase-sync": "mailchimp/mailchimp-firebase-sync@0.5.2",
    "firestore-semantic-search": "googlecloud/firestore-semantic-search@0.1.7"
  }
}

$ firebase deploy --only extensions --project "$GOOGLE_CLOUD_PROJECT"
i  extensions: By installing an extension instance onto a Firebase project, you accept the Firebase Extensions User Terms of Service: https://firebase.google.com/terms/extensions/user

Error: HTTP Error: 403, Mobile SDK API has not been used in project 339893162765 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/mobilesdk-pa.googleapis.com/overview?project=339893162765 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
i  extensions: Verifying secret params for firestore-send-email
(node:573) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(Use `node --trace-warnings ...` to show where the warning was created)

firestore-send-email firestore-semantic-search

From fresh firebase project, first:

$ cat firebase.json
{
  "extensions": {
    "firestore-send-email": "firebase/firestore-send-email@0.1.26",
    "firestore-semantic-search": "googlecloud/firestore-semantic-search@0.1.7"
  }
}

$ firebase deploy --only extensions --project "$GOOGLE_CLOUD_PROJECT"
...
✔  Deploy complete!

then:

$ cat firebase.json
{
  "extensions": {
    "firestore-send-email": "firebase/firestore-send-email@0.1.26",
    "mailchimp-firebase-sync": "mailchimp/mailchimp-firebase-sync@0.5.2",
    "firestore-semantic-search": "googlecloud/firestore-semantic-search@0.1.7"
  }
}

$ firebase deploy --only extensions --project "$GOOGLE_CLOUD_PROJECT"
i  extensions: By installing an extension instance onto a Firebase project, you accept the Firebase Extensions User Terms of Service: https://firebase.google.com/terms/extensions/user

Error: HTTP Error: 403, Mobile SDK API has not been used in project 339893162765 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/mobilesdk-pa.googleapis.com/overview?project=339893162765 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
i  extensions: Verifying secret params for firestore-send-email
(node:573) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(Use `node --trace-warnings ...` to show where the warning was created)

firestore-send-email mailchimp-firebase-sync

From fresh firebase project, first:

$ cat firebase.json
{
  "extensions": {
    "firestore-send-email": "firebase/firestore-send-email@0.1.26",
    "mailchimp-firebase-sync": "mailchimp/mailchimp-firebase-sync@0.5.2"
  }
}

$ firebase deploy --only extensions --project "$GOOGLE_CLOUD_PROJECT"
...
✔  Deploy complete!

then:

$ cat firebase.json
{
  "extensions": {
    "firestore-send-email": "firebase/firestore-send-email@0.1.26",
    "mailchimp-firebase-sync": "mailchimp/mailchimp-firebase-sync@0.5.2",
    "firestore-semantic-search": "googlecloud/firestore-semantic-search@0.1.7"
  }
}

$ firebase deploy --only extensions --project "$GOOGLE_CLOUD_PROJECT"
i  extensions: By installing an extension instance onto a Firebase project, you accept the Firebase Extensions User Terms of Service: https://firebase.google.com/terms/extensions/user

Error: HTTP Error: 403, Mobile SDK API has not been used in project 339893162765 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/mobilesdk-pa.googleapis.com/overview?project=339893162765 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
i  extensions: Verifying secret params for firestore-send-email
(node:573) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(Use `node --trace-warnings ...` to show where the warning was created)

firestore-semantic-search mailchimp-firebase-sync

From fresh firebase project, first:

$ cat firebase.json
{
  "extensions": {
    "firestore-semantic-search": "googlecloud/firestore-semantic-search@0.1.7",
    "mailchimp-firebase-sync": "mailchimp/mailchimp-firebase-sync@0.5.2"
  }
}

$ firebase deploy --only extensions --project "$GOOGLE_CLOUD_PROJECT"
i  extensions: By installing an extension instance onto a Firebase project, you accept the Firebase Extensions User Terms of Service: https://firebase.google.com/terms/extensions/user

Error: HTTP Error: 403, Mobile SDK API has not been used in project 339893162765 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/mobilesdk-pa.googleapis.com/overview?project=339893162765 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
i  extensions: Verifying secret params for firestore-send-email
(node:573) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(Use `node --trace-warnings ...` to show where the warning was created)

one by one

Even if I install:

  1. mailchimp-firebase-sync
  2. firestore-send-mail
  3. firestore-semantic-search

still:

$ cat firebase.json
{
  "extensions": {
    "firestore-send-email": "firebase/firestore-send-email@0.1.26",
    "mailchimp-firebase-sync": "mailchimp/mailchimp-firebase-sync@0.5.2",
    "firestore-semantic-search": "googlecloud/firestore-semantic-search@0.1.7"
  }
}

$ firebase deploy --only extensions --project "$GOOGLE_CLOUD_PROJECT"
i  extensions: By installing an extension instance onto a Firebase project, you accept the Firebase Extensions User Terms of Service: https://firebase.google.com/terms/extensions/user

Error: HTTP Error: 403, Mobile SDK API has not been used in project 339893162765 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/mobilesdk-pa.googleapis.com/overview?project=339893162765 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
i  extensions: Verifying secret params for firestore-send-email
(node:573) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(Use `node --trace-warnings ...` to show where the warning was created)
joehan commented 10 months ago

Hey @yellowhat, sorry to hear that you're running into this. Unfortunately, this is a known issue for now and the workaround is not authenticate via service account (consider https://firebase.google.com/docs/cli#cli-ci-systems instead). There are 2 error messages here:

1 - Error when checking App Developer TOS for xxx. This is expected if authenticated via a service account This is actually a warning - as long as you've accepted the TOS separately, this won't be blocking.

2 - Mobile SDK API has not been used in project 339893162765 before or it is disabled.

Both of these are caused because the CLI calls a private API. Normally, this works fine - however, when authenticating via a service account, these calls are directed to the service account's project, which cannot have the private API enabled.

We've got a fix in the works to use a different API for 2 that should alleviate this issue. Once that is ready, I'll come back and verify that this issue is resolved.

yellowhat commented 10 months ago

Thank you very much for your reply. I will wait for your fix.

But why I can install each extension one by one and all together throw that error?