14

I setup Firebase app distribution feature in Fastlane Fastfile to distribute beta version of my iOS app. It was working fine but It suddenly started showing errors.

This is how my lane looks like.

lane :distribute_beta do |options|
        
        sync_code_signing_adhoc()
        update_build_number_of_all_frameworks() 
        build_ios_app_adhoc()

        firebase_app_distribution(
            app: "<app ID here>",
            testers: "<tester emials here>",
            release_notes: options[:release_note],
            firebase_cli_path: "/usr/local/bin/firebase"
        )
end  

When I run this lane it shows error

the server responded with status 403

on Step: firebase_app_distribution

Log also says authentication to google succeeded.

 Authenticating with GOOGLE_APPLICATION_CREDENTIALS environment variable: /<path to cred>/<cred_file_name>.json
  Authenticated successfully.

Following is entire error around "Step: firebase_app_distribution "

[17:11:04]: ---------------------------------------
[17:11:04]: --- Step: firebase_app_distribution ---
[17:11:04]: ---------------------------------------
[17:11:04]: Authenticating with GOOGLE_APPLICATION_CREDENTIALS environment variable: /<path to cred>/<cred_file_name>.json
[17:11:04]:  Authenticated successfully.
+------------------------------------+---------------------------------------------+
|                                   Lane Context                                   |
+------------------------------------+---------------------------------------------+
| DEFAULT_PLATFORM                   | ios                                         |
| PLATFORM_NAME                      | ios                                         |
| LANE_NAME                          | ios distribute_beta                         |
| SIGH_PROFILE_TYPE                  | ad-hoc                                      |
| MATCH_PROVISIONING_PROFILE_MAPPING | {"<my bndle ID>"=>"match AdHoc              |
|                                    | <my bundle ID>"}                            |
| BUILD_NUMBER                       | 107                                         |
| IPA_OUTPUT_PATH                    | /Users/my_user_name/Repository/App/App|
|                                    | y/App.ipa                                   |
| XCODEBUILD_ARCHIVE                 | /Users/my_user_name/Library/Developer/Xcode/A|
|                                    | rchives/2021-01-08/App 2021-01-08           |
|                                    | 17.09.08.xcarchive                          |
| DSYM_OUTPUT_PATH                   | /Users/my_user_name/Repository/App/App           |
|                                    | y/App.app.dSYM.zip                          |
+------------------------------------+---------------------------------------------+
[17:11:06]: the server responded with status 403

+------+-----------------------------+-------------+
|                 fastlane summary                 |
+------+-----------------------------+-------------+
| Step | Action                      | Time (in s) |
+------+-----------------------------+-------------+
| 1    | default_platform            | 0           |
| 2    | Switch to ios               | 0           |
|      | sync_code_signing_adhoc     |             |
|      | lane                        |             |
| 3    | sync_code_signing           | 18          |
| 4    | Switch to ios               | 0           |
|      | update_build_number_of_all  |             |
|      | _frameworks lane            |             |
| 5    | increment_build_number      | 1           |
| 6    | commit_version_bump         | 0           |
| 7    | Switch to ios               | 0           |
|      | build_ios_app_adhoc lane    |             |
| 8    | build_ios_app               | 126         |
|    | firebase_app_distribution   | 1           |
+------+-----------------------------+-------------+

[17:11:06]: fastlane finished with errors

How can I fix this?

Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
Bigair
  • 1,452
  • 3
  • 15
  • 42

7 Answers7

12

Usually, when you get that specific message it means that the Firebase Refresh Token is no longer valid.

So, when you submit the app, at some point, you have to specify the Firebase Refresh Token:

...
firebase_app_distrubution(
  ...
  firebase_cli_token: "<YourFirebaseRefreshToken>"
)
...

You can get this token from here. If your script started to fail out of nowhere, that probably means that whoever generated this (or any other authentication token) got removed from the Firebase project.

If you're getting a 403 that definitely means that either someone got removed from your Firebase project or that someone removed/regenerated a token on the Firebase console.

4gus71n
  • 3,717
  • 3
  • 39
  • 66
  • I hadn't run beta deploy code for a while so I possible that refresh token was expired, I'll check it out – Bigair Jan 13 '21 at 09:26
  • 1
    if you are using service account for authenticating with Firebase, make sure that this service account has "Firebase App Distribution Admin" role – adjustment layer Dec 05 '22 at 10:45
6

As for me, it was because the service account that I am using does not have Firebase App Distribution Admin role. https://firebase.google.com/docs/app-distribution/authenticate-service-account?platform=ios

I simply had to edit my existing service, to do that, go to firebase console > project settings > Service accounts > then click on the service accounts as shown in the image below

enter image description here

It will take you to GCP IAM and Admin where you can find and edit the role of your service account.

aprilmintacpineda
  • 1,114
  • 13
  • 21
5
  1. Simply run the following command on console:

    curl -sL https://firebase.tools | bash
    
  2. then, authenticate on the browser

  3. Then run

    firebase login:ci
    
  4. After success you will get printed your new cli token, like this:

Waiting for authentication...

✔  Success! Use this token to login on a CI server:

1//here_will_be_your_new_token

Example: firebase deploy --token "$FIREBASE_TOKEN"
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
0

For me, I had to add the particular account I was using for App Distribution login to the Project settings for my app.

enter image description here

RealityExpander
  • 133
  • 1
  • 8
0

Check that your firebase account have distribution permission for project. Project settings -> Users and permissions -> Member should be with "Editor" role

phnmnn
  • 12,813
  • 11
  • 47
  • 64
0

Also, make sure that you are logged in with an appropriate account (the reason for my error ).

Genix
  • 153
  • 1
  • 9
0

Another thing to check is whether your App ID is set correctly. You can find it in the Firebase project settings.

You might hit this problem when you create a new app flavor (like dev vs. prod, acceptance etc) and you forget to update the app_id or serviceAccount file

Nino van Hooff
  • 3,677
  • 1
  • 36
  • 52