Change the project

You switch project by running $ firebase use <project-id>.

Update the Firebase config in the web app

Since we changed project, we have to update the Firebase config in src/firebase.ts and src/index.tsx, in these two places you need to change the config passed to initializeApp to match your firebase project.

Update the Twitch App

You’ll need to create your own application in the Twitch developer console and then update the following files:

  • functions index.ts, you need to update the callback in twitchAuth to no longer redirect to rtirl.com.
  • App.tsx, update TWITCH_CLIENT_ID to match your Twitch client id.

Update Mapbox Access Token

Update the Mapbox access token in src/Map.tsx.

Enable IAM

Unhandled error FirebaseAuthError: IAM Service Account Credentials API has not been used in project 561168452030 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/iamcredentials.googleapis.com/overview?project=561168452030 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.; Please refer to https://firebase.google.com/docs/auth/admin/create-custom-tokens for more details on how to use and troubleshoot this feature.
    at FirebaseAuthError.FirebaseError [as constructor] (/workspace/node_modules/firebase-admin/lib/utils/error.js:44:28)
    at FirebaseAuthError.PrefixedFirebaseError [as constructor] (/workspace/node_modules/firebase-admin/lib/utils/error.js:90:28)
    at new FirebaseAuthError (/workspace/node_modules/firebase-admin/lib/utils/error.js:149:16)
    at Function.FirebaseAuthError.fromServerError (/workspace/node_modules/firebase-admin/lib/utils/error.js:188:16)
    at handleCryptoSignerError (/workspace/node_modules/firebase-admin/lib/auth/token-generator.js:182:46)
    at /workspace/node_modules/firebase-admin/lib/auth/token-generator.js:141:19
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at /workspace/src/index.ts:118:17
    at /workspace/node_modules/firebase-functions/lib/common/providers/https.js:404:26 {
  errorInfo: {
    code: 'auth/insufficient-permission',
    message: 'IAM Service Account Credentials API has not been used in project 561168452030 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/iamcredentials.googleapis.com/overview?project=561168452030 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.; Please refer to https://firebase.google.com/docs/auth/admin/create-custom-tokens for more details on how to use and troubleshoot this feature.'
  },
  codePrefix: 'auth'
} 

The account that neeeds to receive the “Service Account Token Creator” role is the one ending in “@appspot.gserviceaccount.com” see

IAP Setup

Since the app now has IAPs, you’ll need to set up both the Play Store and the App store, the steps are detailed here.

Set up payment verification

  • Get access to the GCP account thats linked to the Play Store, it is not the same as the Firebase project.
  • From the GCP console for the linked account, go to IAM and create a new service account, make it an Editor and generate a key in JSON format. Download it and keep it for now.
  • Go back to the Play Console, make sure API Access is enabled (only the account owner can enable it), then go to All Apps > Users and permissions, there, invite the service account that you just created, it should like like “acc-name@something-else.iam.gserviceaccount.com”, make sure that account has permissions to the corresponding app and that it has access to “Financial Data”, both “View financial data” & “Manage orders and subscriptions”.
  • Since we need to act as this account from the firebase function for verification, we have a secret in Secret Manager that contains the JSON we downloaded earlier, make sure you format it as a one line string and to not escape line breaks 🤷‍♂️

Since we also do server to server order updates, we need to set up a pub/sub resource in the GCP account for the Firebase project:

  • Create a topic named “play_billing”
  • Add a principal for “google-play-developer-notifications@system.gserviceaccount.com” with role “Pub/Sub Publisher”.
  • From the Play Console, go to Monetize > Monetization Setup and fill in the topic name with the proper format “projects/{project_id}/topics/{topic_name}“

Set up Play Store testers

  • Release > Testing > Internal testing, add users to the “Muxable Internal Testers” list, the email should match the one that you use to log in in the device you’re testing on.
  • All Apps > Settings > License Testing, add the same email you added before and make sure License Response is set to RESPOND_NORMALLY

It may take some time before you get the test payment method on the account, I am not sure how long and if logging out/in and restarting the device matters.

Notes

  • Payment testing on iOS: You need both a mac and an iPhone to test.