Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication credentials are missing or invalid. - Provide a properly configured and signed bearer token, and make sure that it has not expired #19072

Closed
khoogheem opened this issue Jul 10, 2021 · 34 comments

Comments

@khoogheem
Copy link

New Issue Checklist

Issue Description

Started receiving the Authentication credentials are missing or invalid. - Provide a properly configured and signed bearer token, and make sure that it has not expired message..

We had not changed anything in our Fastlane and the API Keys have not been revoked.
I have even tested by creating a new API Key on the itunesConnect.

Command executed
      api_key = app_store_connect_api_key(
        key_id: "GXXXXXX",
        issuer_id: "69a6de85-xxxxxx-5b8c7c11a4d1",
        key_content: "-----BEGIN PRIVATE KEY-----\nMIqjg1/eUB\nLxxyWE/va\nBWxxxQW3zb\n-----END PRIVATE KEY-----",
        in_house: false
      )

      sigh(
        api_key: api_key,
        adhoc: true,
        force: true
      )

I have also tied to just use CI env var which no change.

Complete output when running fastlane, including the stack trace and command used

Authentication credentials are missing or invalid. - Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests https://developer.apple.com/go/?id=api-generating-tokens

@fastlane-bot
Copy link

It seems like you have not included the output of fastlane env
To make it easier for us help you resolve this issue, please update the issue to include the output of fastlane env 👍

@khoogheem
Copy link
Author

I should probably mention the key is created with role App Manager

@crazymanish
Copy link
Member

Hi @khoogheem

Can you try sigh using the Admin role? https://developer.apple.com/support/roles/
If you will face an issue with the Admin role too...requesting you to start a discussion here
https://github.com/fastlane/fastlane/discussions/categories/q-a
.
Screenshot 2021-07-10 at 21 05 10

@khoogheem
Copy link
Author

Same issue with Admin

@khoogheem
Copy link
Author

khoogheem commented Jul 10, 2021

@crazymanish I think there is an issue regardless.. I tested by putting everything into a json so I could just run
fastlane sigh --api_key_path fastlane/api_key_admin.json
NO Duration set - Doesn't Work
Duration of 1200: Doesn't work
Duration of 800: Doesn't work
Duration of 500: 👍 works

@crazymanish
Copy link
Member

this is interesting...reopening

@formatCvt
Copy link
Contributor

formatCvt commented Jul 11, 2021

same issue (without duration)

@IlyaKiselevKolibri
Copy link

We are having the same issue using the key with the admin role:


12:30:33  [11:30:36]: Verifying that the certificate and profile are still valid on the Dev Portal...

12:30:33  [11:30:36]: Creating authorization token for App Store Connect API

12:30:34  [11:30:36]: #<Spaceship::UnauthorizedAccessError: Authentication credentials are missing or invalid. - Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests https://developer.apple.com/go/?id=api-generating-tokens>```

@crazymanish
Copy link
Member

Okay, cool! I am not sure why this is causing this suddenly, don't have an AppStoreConnectAPI key to debug this issue. 🤪
I am tagging @joshdholtz for this issue! 😇

@MatejBalantic
Copy link

We are seeing the same issue suddenly with a key that was working fine. It does look like an issue with Apple's API, given that I am unable to create a new token in the App Store Connect, seeing bunch of 500 errors in the developer console.

@dehlen
Copy link

dehlen commented Jul 12, 2021

Seems like AppStore Connect has some problems atm? I get an error message and can't see any apps when logging in via Safari.

@florieger
Copy link

Same issue, AppStore Connect website shows error message instead of apps.

@florieger
Copy link

Seems to be fixed.

@IlyaKiselevKolibri
Copy link

Not sure if the AppStore Connect issue was related though, as for us the initial problem with the Auth is there since Friday evening.

@khoogheem
Copy link
Author

Right.. My issues started on my Thursday/Friday builds..

Sure it might still be an Apple Issue.. but what made no sense was the default durations just stopped working.. and I could only get it to work with a duration of 500

@IlyaKiselevKolibri
Copy link

Totally! I can confirm that duration of 500 also does the trick for us.

@crazymanish
Copy link
Member

Adding 500 seconds duration sounds crazy workaround, but I don't surprise with Apple 🍏🍎 anymore 😇😂

@weakfl
Copy link

weakfl commented Jul 13, 2021

Doesn't work for us, even with duration set to 500.

@cdoky
Copy link
Contributor

cdoky commented Jul 13, 2021

It does work for me

Adding 500 seconds duration sounds crazy workaround, but I don't surprise with Apple 🍏🍎 anymore 😇😂

@yakimant
Copy link

We didn't change anything (like duration), but it started to work again.

@itismadhan
Copy link

Can confirm that setting the duration to 500 fixes the issue.

@pvroosendaal
Copy link

Adding 500 seconds duration works for us too.

@crazymanish
Copy link
Member

Hi all,
I am closing this as this seems to be a temporary Apple issue, if something crazy will happen again, maybe we can submit Radar? 🤔 (Radar project was a mess 5years ago when I work on macOS client in Apple 🤪)

btw, In my team, we don't use any duration and everything seems to work so far... 😉

@jacksonsmith
Copy link

@crazymanish I think there is an issue regardless.. I tested by putting everything into a json so I could just run
fastlane sigh --api_key_path fastlane/api_key_admin.json
NO Duration set - Doesn't Work
Duration of 1200: Doesn't work
Duration of 800: Doesn't work
Duration of 500: 👍 works

this work for us | paring with @fernandaaraujo

@jonbenk
Copy link

jonbenk commented Jul 20, 2021

Hi all,

I'm facing the same issue here. Does anyone know how to change the token session duration on the Azure DevOps extension for the Apple App Store? Would it be possible via additional fastlane arguments on the task or using an environment variable? Thanks in advance!

@styrken
Copy link

styrken commented Aug 1, 2021

Works for me too with duration 500 🥇

@ryanjwessel
Copy link

My team was experiencing this issue when we had the duration set to 500. We increased that value to 1200, which solved it for a time, but now seem to be experiencing it again.

Do we know what might be the root cause of this issue? Modifying the duration is a flaky solution, especially when deploying app versions via CI/CD.

@joshuawright11
Copy link

Also encountered this; not exactly relevant since I'm using GitHub actions but it seems like the same underlying issue.

For me a retrigger of the GitHub Actions workflow always works; wondering if it's something to do with a rate limit on Apple's side that returns an unhelpful error message.

@DuMaM
Copy link
Contributor

DuMaM commented Sep 22, 2021

I'm facing this issue again since 5days...
what's it's interesting when I use app_store_connect_api_key again, then it works fine in second run...
I got duration set on: 1200

[17:03:27]: Setting Provisioning Profile type to 'development'
[17:14:33]: Authentication credentials are missing or invalid. - Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests https://developer.apple.com/go/?id=api-generating-tokens

I think that there maybe an issue on apple with generation such keys, and then it produces one with default values.

andersonvom pushed a commit to andersonvom/fastlane that referenced this issue Oct 20, 2021
Apple seems to be revoking tokens before their expiration dates. Several
users reporting problems on issue [fastlane#19072][1] were likely affected by
it. Sometimes changing the token duration will work around the problem,
as the tokens are likely being revoked later in the future and allowing
the wait to complete.

This can be seen in practice by adding a `@token.refresh!` couple of extra log
messages to [api_client.rb][2] right at the point where we get an
`UnauthorizedAccessError`:

```
INFO  [2021-10-19 18:38:31.74]: Successfully uploaded the new binary to App Store Connect
INFO  [2021-10-19 18:38:31.74]: If you want to skip waiting for the processing to be finished, use the `skip_waiting_for_build_processing` option
INFO  [2021-10-19 18:38:31.74]: Note that if `skip_waiting_for_build_processing` is used but a `changelog` is supplied, this process will wait for the build to appear on AppStoreConnect, update the changelog and then skip the remaining of the processing steps.
DEBUG [2021-10-19 18:38:31.82]: App Platform (ios)
INFO  [2021-10-19 18:38:31.92]: Waiting for processing on... app_id: 1370986669, app_version: 2.23.2, build_version: 262025, platform: IOS
WARN  [2021-10-19 18:38:32.26]: Read more information on why this build isn't showing up yet - fastlane#14997
INFO  [2021-10-19 18:38:32.26]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:39:02.70]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)

token expired?: false  - expiration: 2021-10-19 18:45:04 -0400
Token has expired, has been revoked, or is invalid! Trying to refresh

INFO  [2021-10-19 18:39:33.26]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:40:03.69]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:40:34.33]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:41:04.76]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:41:35.21]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:42:05.67]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)

token expired?: false  - expiration: 2021-10-19 18:47:52 -0400
Token has expired, has been revoked, or is invalid! Trying to refresh

INFO  [2021-10-19 18:42:36.34]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:43:06.80]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:43:37.23]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
```

The logs above show that, even though the current token is not expired, the
appconnect API responds with a 401 and the process would otherwise fail.

This ignores the `UnauthorizedAccessError` exception and instead refreshes the
token right before raising a `RetryError`.

[1]: fastlane#19072
[2]: https://github.com/fastlane/fastlane/blob/62af236780a9eace9d0487d0767f50d1a17a1c6c/spaceship/lib/spaceship/connect_api/api_client.rb#L172-L175
andersonvom added a commit to andersonvom/fastlane that referenced this issue Oct 20, 2021
Apple seems to be revoking tokens before their expiration dates. Several
users reporting problems on issue [fastlane#19072][1] were likely affected by
it. Sometimes changing the token duration will work around the problem,
as the tokens are likely being revoked later in the future and allowing
the wait to complete.

This can be seen in practice by adding a `@token.refresh!` couple of extra log
messages to [api_client.rb][2] right at the point where we get an
`UnauthorizedAccessError`:

```
INFO  [2021-10-19 18:38:31.74]: Successfully uploaded the new binary to App Store Connect
INFO  [2021-10-19 18:38:31.74]: If you want to skip waiting for the processing to be finished, use the `skip_waiting_for_build_processing` option
INFO  [2021-10-19 18:38:31.74]: Note that if `skip_waiting_for_build_processing` is used but a `changelog` is supplied, this process will wait for the build to appear on AppStoreConnect, update the changelog and then skip the remaining of the processing steps.
DEBUG [2021-10-19 18:38:31.82]: App Platform (ios)
INFO  [2021-10-19 18:38:31.92]: Waiting for processing on... app_id: 1370986669, app_version: 2.23.2, build_version: 262025, platform: IOS
WARN  [2021-10-19 18:38:32.26]: Read more information on why this build isn't showing up yet - fastlane#14997
INFO  [2021-10-19 18:38:32.26]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:39:02.70]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)

token expired?: false  - expiration: 2021-10-19 18:45:04 -0400
Token has expired, has been revoked, or is invalid! Trying to refresh

INFO  [2021-10-19 18:39:33.26]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:40:03.69]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:40:34.33]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:41:04.76]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:41:35.21]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:42:05.67]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)

token expired?: false  - expiration: 2021-10-19 18:47:52 -0400
Token has expired, has been revoked, or is invalid! Trying to refresh

INFO  [2021-10-19 18:42:36.34]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:43:06.80]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:43:37.23]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
```

The logs above show that, even though the current token is not expired, the
appconnect API responds with a 401 and the process would otherwise fail.

This ignores the `UnauthorizedAccessError` exception and instead refreshes the
token right before raising a `RetryError`.

[1]: fastlane#19072
[2]: https://github.com/fastlane/fastlane/blob/62af236780a9eace9d0487d0767f50d1a17a1c6c/spaceship/lib/spaceship/connect_api/api_client.rb#L172-L175
@abdulbasit18
Copy link

abdulbasit18 commented Nov 11, 2021

@crazymanish I think there is an issue regardless.. I tested by putting everything into a json so I could just run fastlane sigh --api_key_path fastlane/api_key_admin.json NO Duration set - Doesn't Work Duration of 1200: Doesn't work Duration of 800: Doesn't work Duration of 500: 👍 works

@khoogheem Hi I am facing the same issue , but I don't understand where I can add this duration in fastfile and I don't understand the Json file solution

    app_store_connect_api_key(
       key_id: "XXXXXXXXXXX",
       issuer_id: "XXXXXXXXXXXXXXXXXXXXXX",
       key_content: "XXXXXXXXXXXXXXXXX",
       
       is_key_content_base64: true,
       in_house: false #boolean value if team is Enterprise or not
     )


    # Get the required provisioning profiles
    bundle_identifiers.each do |identifier|
      sigh app_identifier: identifier,
           provisioning_name: provisioning_profile_name(identifier, export_method),
           adhoc: export_method == :adhoc,
           force: export_method == :adhoc
    end

andersonvom added a commit to andersonvom/fastlane that referenced this issue Dec 6, 2021
Apple seems to be revoking tokens before their expiration dates. Several
users reporting problems on issue [fastlane#19072][1] were likely affected by
it. Sometimes changing the token duration will work around the problem,
as the tokens are likely being revoked later in the future and allowing
the wait to complete.

This can be seen in practice by adding a `@token.refresh!` couple of extra log
messages to [api_client.rb][2] right at the point where we get an
`UnauthorizedAccessError`:

```
INFO  [2021-10-19 18:38:31.74]: Successfully uploaded the new binary to App Store Connect
INFO  [2021-10-19 18:38:31.74]: If you want to skip waiting for the processing to be finished, use the `skip_waiting_for_build_processing` option
INFO  [2021-10-19 18:38:31.74]: Note that if `skip_waiting_for_build_processing` is used but a `changelog` is supplied, this process will wait for the build to appear on AppStoreConnect, update the changelog and then skip the remaining of the processing steps.
DEBUG [2021-10-19 18:38:31.82]: App Platform (ios)
INFO  [2021-10-19 18:38:31.92]: Waiting for processing on... app_id: 1370986669, app_version: 2.23.2, build_version: 262025, platform: IOS
WARN  [2021-10-19 18:38:32.26]: Read more information on why this build isn't showing up yet - fastlane#14997
INFO  [2021-10-19 18:38:32.26]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:39:02.70]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)

token expired?: false  - expiration: 2021-10-19 18:45:04 -0400
Token has expired, has been revoked, or is invalid! Trying to refresh

INFO  [2021-10-19 18:39:33.26]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:40:03.69]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:40:34.33]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:41:04.76]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:41:35.21]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:42:05.67]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)

token expired?: false  - expiration: 2021-10-19 18:47:52 -0400
Token has expired, has been revoked, or is invalid! Trying to refresh

INFO  [2021-10-19 18:42:36.34]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:43:06.80]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:43:37.23]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
```

The logs above show that, even though the current token is not expired, the
appconnect API responds with a 401 and the process would otherwise fail.

This refreshes the token and adds retries to `UnauthorizedAccessError`
before ultimately raising the error if it still continues to fail.

[1]: fastlane#19072
[2]: https://github.com/fastlane/fastlane/blob/62af236780a9eace9d0487d0767f50d1a17a1c6c/spaceship/lib/spaceship/connect_api/api_client.rb#L172-L175
andersonvom added a commit to andersonvom/fastlane that referenced this issue Dec 17, 2021
Apple seems to be revoking tokens before their expiration dates. Several
users reporting problems on issue [fastlane#19072][1] were likely affected by
it. Sometimes changing the token duration will work around the problem,
as the tokens are likely being revoked later in the future and allowing
the wait to complete.

This can be seen in practice by adding a `@token.refresh!` couple of extra log
messages to [api_client.rb][2] right at the point where we get an
`UnauthorizedAccessError`:

```
INFO  [2021-10-19 18:38:31.74]: Successfully uploaded the new binary to App Store Connect
INFO  [2021-10-19 18:38:31.74]: If you want to skip waiting for the processing to be finished, use the `skip_waiting_for_build_processing` option
INFO  [2021-10-19 18:38:31.74]: Note that if `skip_waiting_for_build_processing` is used but a `changelog` is supplied, this process will wait for the build to appear on AppStoreConnect, update the changelog and then skip the remaining of the processing steps.
DEBUG [2021-10-19 18:38:31.82]: App Platform (ios)
INFO  [2021-10-19 18:38:31.92]: Waiting for processing on... app_id: 1370986669, app_version: 2.23.2, build_version: 262025, platform: IOS
WARN  [2021-10-19 18:38:32.26]: Read more information on why this build isn't showing up yet - fastlane#14997
INFO  [2021-10-19 18:38:32.26]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:39:02.70]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)

token expired?: false  - expiration: 2021-10-19 18:45:04 -0400
Token has expired, has been revoked, or is invalid! Trying to refresh

INFO  [2021-10-19 18:39:33.26]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:40:03.69]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:40:34.33]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:41:04.76]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:41:35.21]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:42:05.67]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)

token expired?: false  - expiration: 2021-10-19 18:47:52 -0400
Token has expired, has been revoked, or is invalid! Trying to refresh

INFO  [2021-10-19 18:42:36.34]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:43:06.80]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:43:37.23]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
```

The logs above show that, even though the current token is not expired, the
appconnect API responds with a 401 and the process would otherwise fail.

This refreshes the token and adds retries to `UnauthorizedAccessError`
before ultimately raising the error if it still continues to fail.

[1]: fastlane#19072
[2]: https://github.com/fastlane/fastlane/blob/62af236780a9eace9d0487d0767f50d1a17a1c6c/spaceship/lib/spaceship/connect_api/api_client.rb#L172-L175
@uiuco
Copy link

uiuco commented Dec 30, 2021

How to fundamentally solve this problem?

This problem started to appear around November 15th.
Even if I set the duration to 500, this problem occasionally occurs when packaging.
But if I call it again, the problem does not appear.
How to fundamentally solve this problem?

    app_store_connect_api_key(
      key_id: key_id,
      issuer_id: issuer_id,
      key_content: key_content,
      duration: 500, # maximum 1200
      in_house: false # optional but may be required if using match/sigh
    )

@DuMaM
Copy link
Contributor

DuMaM commented Dec 30, 2021

@wangdetong Take a look on @andersonvom #19502
I think it will solve this issues or at least reduce it. I'm also facing this problem for quite long time.

@uiuco
Copy link

uiuco commented Dec 31, 2021

@wangdetong Take a look on @andersonvom #19502 I think it will solve this issues or at least reduce it. I'm also facing this problem for quite long time.

Thank you, I will try

@andersonvom
Copy link
Contributor

andersonvom commented Dec 31, 2021

@DuMaM @wangdetong for what it's worth, after adding the changes from #19502 locally, my team and I have not seen this issue again: we can see in the logs that the failed requests are able to recover after a token refresh.

Side note: Happy 2022, everyone! 🥳

PaulTaykalo pushed a commit to PaulTaykalo/fastlane that referenced this issue Feb 9, 2022
Apple seems to be revoking tokens before their expiration dates. Several
users reporting problems on issue [fastlane#19072][1] were likely affected by
it. Sometimes changing the token duration will work around the problem,
as the tokens are likely being revoked later in the future and allowing
the wait to complete.

This can be seen in practice by adding a `@token.refresh!` couple of extra log
messages to [api_client.rb][2] right at the point where we get an
`UnauthorizedAccessError`:

```
INFO  [2021-10-19 18:38:31.74]: Successfully uploaded the new binary to App Store Connect
INFO  [2021-10-19 18:38:31.74]: If you want to skip waiting for the processing to be finished, use the `skip_waiting_for_build_processing` option
INFO  [2021-10-19 18:38:31.74]: Note that if `skip_waiting_for_build_processing` is used but a `changelog` is supplied, this process will wait for the build to appear on AppStoreConnect, update the changelog and then skip the remaining of the processing steps.
DEBUG [2021-10-19 18:38:31.82]: App Platform (ios)
INFO  [2021-10-19 18:38:31.92]: Waiting for processing on... app_id: 1370986669, app_version: 2.23.2, build_version: 262025, platform: IOS
WARN  [2021-10-19 18:38:32.26]: Read more information on why this build isn't showing up yet - fastlane#14997
INFO  [2021-10-19 18:38:32.26]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:39:02.70]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)

token expired?: false  - expiration: 2021-10-19 18:45:04 -0400
Token has expired, has been revoked, or is invalid! Trying to refresh

INFO  [2021-10-19 18:39:33.26]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:40:03.69]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:40:34.33]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:41:04.76]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:41:35.21]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:42:05.67]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)

token expired?: false  - expiration: 2021-10-19 18:47:52 -0400
Token has expired, has been revoked, or is invalid! Trying to refresh

INFO  [2021-10-19 18:42:36.34]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:43:06.80]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:43:37.23]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
```

The logs above show that, even though the current token is not expired, the
appconnect API responds with a 401 and the process would otherwise fail.

This refreshes the token and adds retries to `UnauthorizedAccessError`
before ultimately raising the error if it still continues to fail.

[1]: fastlane#19072
[2]: https://github.com/fastlane/fastlane/blob/62af236780a9eace9d0487d0767f50d1a17a1c6c/spaceship/lib/spaceship/connect_api/api_client.rb#L172-L175
PaulTaykalo pushed a commit to PaulTaykalo/fastlane that referenced this issue Feb 9, 2022
Apple seems to be revoking tokens before their expiration dates. Several
users reporting problems on issue [fastlane#19072][1] were likely affected by
it. Sometimes changing the token duration will work around the problem,
as the tokens are likely being revoked later in the future and allowing
the wait to complete.

This can be seen in practice by adding a `@token.refresh!` couple of extra log
messages to [api_client.rb][2] right at the point where we get an
`UnauthorizedAccessError`:

```
INFO  [2021-10-19 18:38:31.74]: Successfully uploaded the new binary to App Store Connect
INFO  [2021-10-19 18:38:31.74]: If you want to skip waiting for the processing to be finished, use the `skip_waiting_for_build_processing` option
INFO  [2021-10-19 18:38:31.74]: Note that if `skip_waiting_for_build_processing` is used but a `changelog` is supplied, this process will wait for the build to appear on AppStoreConnect, update the changelog and then skip the remaining of the processing steps.
DEBUG [2021-10-19 18:38:31.82]: App Platform (ios)
INFO  [2021-10-19 18:38:31.92]: Waiting for processing on... app_id: 1370986669, app_version: 2.23.2, build_version: 262025, platform: IOS
WARN  [2021-10-19 18:38:32.26]: Read more information on why this build isn't showing up yet - fastlane#14997
INFO  [2021-10-19 18:38:32.26]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:39:02.70]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)

token expired?: false  - expiration: 2021-10-19 18:45:04 -0400
Token has expired, has been revoked, or is invalid! Trying to refresh

INFO  [2021-10-19 18:39:33.26]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:40:03.69]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:40:34.33]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:41:04.76]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:41:35.21]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:42:05.67]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)

token expired?: false  - expiration: 2021-10-19 18:47:52 -0400
Token has expired, has been revoked, or is invalid! Trying to refresh

INFO  [2021-10-19 18:42:36.34]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:43:06.80]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
INFO  [2021-10-19 18:43:37.23]: Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)
```

The logs above show that, even though the current token is not expired, the
appconnect API responds with a 401 and the process would otherwise fail.

This refreshes the token and adds retries to `UnauthorizedAccessError`
before ultimately raising the error if it still continues to fail.

[1]: fastlane#19072
[2]: https://github.com/fastlane/fastlane/blob/62af236780a9eace9d0487d0767f50d1a17a1c6c/spaceship/lib/spaceship/connect_api/api_client.rb#L172-L175
@fastlane fastlane locked and limited conversation to collaborators Mar 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests