'Firebase app distribution via Fastlane "the server responded with status 403"

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?



Solution 1:[1]

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.

Solution 2:[2]

  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"

Solution 3:[3]

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.

Solution 4:[4]

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

Solution 5:[5]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 4gus71n
Solution 2 Bartłomiej Semańczyk
Solution 3 aprilmintacpineda
Solution 4 RealityExpander
Solution 5 phnmnn