Firebase app distribution via Fastlane "the server responded with status 403"
Asked Answered
A

8

17

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?

Allveta answered 11/1, 2021 at 6:3 Comment(0)
R
16

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.

Rover answered 12/1, 2021 at 22:51 Comment(3)
I hadn't run beta deploy code for a while so I possible that refresh token was expired, I'll check it out – Allveta
if you are using service account for authenticating with Firebase, make sure that this service account has "Firebase App Distribution Admin" role – Stauffer
Still not working. – Yama
B
8

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.

Bedclothes answered 31/3, 2022 at 10:20 Comment(0)
F
6
  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"
Foreknowledge answered 16/9, 2021 at 11:21 Comment(1)
Sadly, this does not work. Still getting 403. – Yama
O
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

Okie answered 6/4, 2022 at 5:54 Comment(0)
R
0

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

Raber answered 4/5, 2022 at 7:42 Comment(0)
D
0

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

Dikdik answered 13/6, 2023 at 12:34 Comment(0)
I
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

Inkwell answered 28/6, 2023 at 10:10 Comment(0)
Y
0

My experience with Firebase App Distribution and Fastlane was a bit different from what's outlined in the tutorial (https://developersancho.medium.com/ci-cd-firebase-app-distribution-with-fastlane-on-android-8ee419f770b7). In the tutorial, it recommends using a private JSON file for authentication, but I encountered some challenges with this approach. Here's what I did to resolve the issue:

Initially, I set up Firebase App Distribution in Fastlane with a private JSON file in my configuration like this:

firebase_app_distribution(
    app: ENV["FIREBASE_APP_ID"],
    apk_path: apk_path,
    release_notes: "#{release_note}",
    groups_file: "fastlane/groups.txt",
    service_credentials_file: ENV["FIREBASE_LOGIN_CREDENTIALS"]
)

However, I found that the private JSON file approach wasn't working for me. I attempted to authenticate using the Firebase CLI and used the token, as some other answers suggested (using firebase_cli_token), but unfortunately, this didn't resolve the issue either.

As a workaround, I decided to remove the usage of the private JSON file from my Fastlane setup, resulting in the following configuration:

firebase_app_distribution(
    app: ENV["FIREBASE_APP_ID"],
    apk_path: apk_path,
    release_notes: "#{release_note}",
    groups_file: "fastlane/groups.txt"
)

After making this change, I encountered an error message from Fastlane stating that it couldn't find any credentials. However, the interesting part is that it proceeded to use "cached Firebase CLI credentials" and miraculously, the distribution process worked.

Yama answered 7/11, 2023 at 14:16 Comment(0)

© 2022 - 2025 β€” McMap. All rights reserved.