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

New Issue Checklist

Issue Description

I’m trying to use Fastlane in Jenkins to automate uploading .ipa file onto Test Flight. Developers built .ipa file, which I uploaded to Bitbucket. Commands in Jenkins below. I have created several App Store API keys with Developer and App Manager permissions to verify that it’s not permission or expiration time issues, but all have produced the error below

INFO [2023-03-06 22:07:23.86]: Creating authorization token for App Store Connect API
DEBUG [2023-03-06 22:07:23.90]: App identifier (com.transamerica.wfg365)
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
Token has expired or has been revoked! Trying to refresh...

Expected behavior: IPA file uploaded to Test Flight Actual behavior: Authentication error message like above Folder structure

Command executed

I have both Fastfile and used fastlane CLI

Commands for fastlane CLI

unzip IPA.zip
fastlane pilot upload --api_key_path ./fastlane/key.json --verbose

Content of key.json

{
        "key_id": "[KEY_ID]",
        "issuer_id": "[ISSUER_ID]",
        "key_content": "-----BEGIN PRIVATE KEY-----\nLINE1\nLINE2\nLINE3\n-----END PRIVATE KEY-----",
        "duration": 100
}

Fastfile content

[2023-03-06T22:07:39.704Z] ruby [2023-03-06T22:07:39.704Z] fastlane_version “2.24.0” [2023-03-06T22:07:39.704Z] default_platform :ios [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] platform :ios do [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] lane :release do [2023-03-06T22:07:39.704Z] api_key = app_store_connect_api_key( [2023-03-06T22:07:39.704Z] key_id: “[KEY_NAME]”, [2023-03-06T22:07:39.704Z] issuer_id: “[ISSUE_ID]”, [2023-03-06T22:07:39.704Z] key_filepath: “./[KEY_NAME].p8”, [2023-03-06T22:07:39.704Z] duration: 1200, # optional (maximum 1200) [2023-03-06T22:07:39.704Z] in_house: false # optional but may be required if using match/sigh [2023-03-06T22:07:39.704Z] ) [2023-03-06T22:07:39.704Z]
[2023-03-06T22:07:39.704Z] pilot(api_key: api_key) [2023-03-06T22:07:39.704Z] end [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] end

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

[2023-03-06T22:07:39.706Z] [22:07:14]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile [2023-03-06T22:07:39.706Z] [22:07:18]: ------------------- [2023-03-06T22:07:39.706Z] [22:07:18]: — Step: debug — [2023-03-06T22:07:39.706Z] [22:07:18]: ------------------- [2023-03-06T22:07:39.706Z] Lane Context [2023-03-06T22:07:39.706Z] {} [2023-03-06T22:07:39.706Z] [22:07:20]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile [2023-03-06T22:07:39.706Z] INFO [2023-03-06 22:07:23.86]: Creating authorization token for App Store Connect API [2023-03-06T22:07:39.706Z] DEBUG [2023-03-06 22:07:23.90]: App identifier (com.transamerica.wfg365) [2023-03-06T22:07:39.706Z] 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 [2023-03-06T22:07:39.706Z] Token has expired or has been revoked! Trying to refresh… [2023-03-06T22:07:39.706Z] Looking for related GitHub issues on fastlane/fastlane… [2023-03-06T22:07:39.706Z] Search query: The request could not be completed because: [2023-03-06T22:07:39.706Z] 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 [2023-03-06T22:07:39.706Z] [2023-03-06T22:07:39.706Z] URL: https://api.github.com/search/issues?q=The request could not be completed because%3A Authentication credentials are missing or invalid. - Provide a properly configured and signed bearer token%2C and make sure that it has not expired. Learn more about Generating Tokens for API Requests https%3A%2F%2Fdeveloper.apple.com%2Fgo%2F%3Fid%3Dapi-generating-tokens+repo:fastlane/fastlane [2023-03-06T22:07:39.706Z] ERROR [2023-03-06 22:07:25.13]: Error finding relevant GitHub issues: undefined method map' for nil:NilClass [2023-03-06T22:07:39.706Z] /var/lib/gems/2.7.0/gems/fastlane-2.212.1/spaceship/lib/spaceship/connect_api/api_client.rb:226:in handle_error’: \e[31m[!] The request could not be completed because: (Spaceship::UnauthorizedAccessError)

Environment

 
[2023-03-06T22:07:39.704Z] | Key                         | Value                                                                        |
[2023-03-06T22:07:39.704Z] | --------------------------- | ---------------------------------------------------------------------------- |
[2023-03-06T22:07:39.704Z] | OS                          | debian_based bullseye/sid                                                    |
[2023-03-06T22:07:39.704Z] | Ruby                        | 2.7.0                                                                        |
[2023-03-06T22:07:39.704Z] | Bundler?                    | false                                                                        |
[2023-03-06T22:07:39.704Z] | Git                         | git version 2.25.1                                                           |
[2023-03-06T22:07:39.704Z] | Installation Source         | /usr/local/bin/fastlane                                                      |
[2023-03-06T22:07:39.704Z] | Host                        | Ubuntu 20.04.5 LTS debian_based bullseye/sid (4.14.301-224.520.amzn2.x86_64) |
[2023-03-06T22:07:39.704Z] | Ruby Lib Dir                | /usr/lib                                                                     |
[2023-03-06T22:07:39.704Z] | OpenSSL Version             | OpenSSL 1.1.1f  31 Mar 2020                                                  |
[2023-03-06T22:07:39.704Z] | Is contained                | false                                                                        |
[2023-03-06T22:07:39.704Z] | Is homebrew                 | false                                                                        |
[2023-03-06T22:07:39.704Z] | Is installed via Fabric.app | false                                                                        |
[2023-03-06T22:07:39.704Z] 
[2023-03-06T22:07:39.704Z] 
[2023-03-06T22:07:39.704Z] ### System Locale
[2023-03-06T22:07:39.704Z] 
[2023-03-06T22:07:39.704Z] | Variable | Value   |   |
[2023-03-06T22:07:39.704Z] | -------- | ------- | - |
[2023-03-06T22:07:39.704Z] | LANG     | C.UTF-8 | ��� |
[2023-03-06T22:07:39.704Z] | LC_ALL   | C.UTF-8 | ��� |
[2023-03-06T22:07:39.704Z] | LANGUAGE |         |   |
[2023-03-06T22:07:39.704Z] 
[2023-03-06T22:07:39.704Z] 
[2023-03-06T22:07:39.704Z] ### fastlane files:
[2023-03-06T22:07:39.704Z] 
[2023-03-06T22:07:39.704Z] 
`./fastlane/Fastfile` [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] ```ruby [2023-03-06T22:07:39.704Z] fastlane_version "2.24.0" [2023-03-06T22:07:39.704Z] default_platform :ios [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] platform :ios do [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] lane :release do [2023-03-06T22:07:39.704Z] api_key = app_store_connect_api_key( [2023-03-06T22:07:39.704Z] key_id: "[KEY_NAME]", [2023-03-06T22:07:39.704Z] issuer_id: "[ISSUE_ID]", [2023-03-06T22:07:39.704Z] key_filepath: "./[KEY_NAME].p8", [2023-03-06T22:07:39.704Z] duration: 1200, # optional (maximum 1200) [2023-03-06T22:07:39.704Z] in_house: false # optional but may be required if using match/sigh [2023-03-06T22:07:39.704Z] ) [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] pilot(api_key: api_key) [2023-03-06T22:07:39.704Z] end [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] end [2023-03-06T22:07:39.704Z] ``` [2023-03-06T22:07:39.704Z]
[2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] **No Appfile found** [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] ### fastlane gems [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] | Gem | Version | Update-Status | [2023-03-06T22:07:39.704Z] | -------- | ------- | ------------- | [2023-03-06T22:07:39.704Z] | fastlane | 2.212.1 | ��� Up-To-Date | [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] ### Loaded fastlane plugins: [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] **No plugins Loaded** [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z]
Loaded gems [2023-03-06T22:07:39.704Z] [2023-03-06T22:07:39.704Z] | Gem | Version | [2023-03-06T22:07:39.704Z] | ------------------------------- | ------------ | [2023-03-06T22:07:39.704Z] | did_you_mean | 1.4.0 | [2023-03-06T22:07:39.704Z] | atomos | 0.1.3 | [2023-03-06T22:07:39.704Z] | CFPropertyList | 3.0.6 | [2023-03-06T22:07:39.704Z] | claide | 1.1.0 | [2023-03-06T22:07:39.704Z] | colored2 | 3.1.2 | [2023-03-06T22:07:39.704Z] | nanaimo | 0.3.0 | [2023-03-06T22:07:39.704Z] | rexml | 3.2.5 | [2023-03-06T22:07:39.704Z] | xcodeproj | 1.22.0 | [2023-03-06T22:07:39.704Z] | rouge | 2.0.7 | [2023-03-06T22:07:39.704Z] | xcpretty | 0.3.0 | [2023-03-06T22:07:39.704Z] | terminal-notifier | 2.0.0 | [2023-03-06T22:07:39.704Z] | unicode-display_width | 1.8.0 | [2023-03-06T22:07:39.704Z] | terminal-table | 1.8.0 | [2023-03-06T22:07:39.704Z] | plist | 3.7.0 | [2023-03-06T22:07:39.704Z] | public_suffix | 5.0.1 | [2023-03-06T22:07:39.704Z] | addressable | 2.8.1 | [2023-03-06T22:07:39.704Z] | multipart-post | 2.0.0 | [2023-03-06T22:07:39.704Z] | word_wrap | 1.0.0 | [2023-03-06T22:07:39.704Z] | optparse | 0.1.1 | [2023-03-06T22:07:39.704Z] | tty-screen | 0.8.1 | [2023-03-06T22:07:39.704Z] | tty-cursor | 0.7.1 | [2023-03-06T22:07:39.704Z] | tty-spinner | 0.9.3 | [2023-03-06T22:07:39.704Z] | artifactory | 3.0.15 | [2023-03-06T22:07:39.704Z] | babosa | 1.0.4 | [2023-03-06T22:07:39.704Z] | colored | 1.2 | [2023-03-06T22:07:39.704Z] | highline | 2.0.3 | [2023-03-06T22:07:39.704Z] | commander | 4.6.0 | [2023-03-06T22:07:39.704Z] | excon | 0.99.0 | [2023-03-06T22:07:39.704Z] | faraday-em_http | 1.0.0 | [2023-03-06T22:07:39.704Z] | faraday-em_synchrony | 1.0.0 | [2023-03-06T22:07:39.704Z] | faraday-excon | 1.1.0 | [2023-03-06T22:07:39.704Z] | faraday-httpclient | 1.0.1 | [2023-03-06T22:07:39.704Z] | faraday-multipart | 1.0.4 | [2023-03-06T22:07:39.704Z] | faraday-net_http | 1.0.1 | [2023-03-06T22:07:39.705Z] | faraday-net_http_persistent | 1.2.0 | [2023-03-06T22:07:39.705Z] | faraday-patron | 1.0.0 | [2023-03-06T22:07:39.705Z] | faraday-rack | 1.0.0 | [2023-03-06T22:07:39.705Z] | faraday-retry | 1.0.3 | [2023-03-06T22:07:39.705Z] | ruby2_keywords | 0.0.5 | [2023-03-06T22:07:39.705Z] | faraday | 1.10.3 | [2023-03-06T22:07:39.705Z] | unf_ext | 0.0.8.2 | [2023-03-06T22:07:39.705Z] | unf | 0.1.4 | [2023-03-06T22:07:39.705Z] | domain_name | 0.5.20190701 | [2023-03-06T22:07:39.705Z] | http-cookie | 1.0.5 | [2023-03-06T22:07:39.705Z] | faraday-cookie_jar | 0.0.7 | [2023-03-06T22:07:39.705Z] | faraday_middleware | 1.2.0 | [2023-03-06T22:07:39.705Z] | fastimage | 2.2.6 | [2023-03-06T22:07:39.705Z] | gh_inspector | 1.1.3 | [2023-03-06T22:07:39.705Z] | json | 2.3.0 | [2023-03-06T22:07:39.705Z] | mini_magick | 4.12.0 | [2023-03-06T22:07:39.705Z] | naturally | 2.2.1 | [2023-03-06T22:07:39.705Z] | rubyzip | 2.3.2 | [2023-03-06T22:07:39.705Z] | security | 0.1.3 | [2023-03-06T22:07:39.705Z] | xcpretty-travis-formatter | 1.0.1 | [2023-03-06T22:07:39.705Z] | dotenv | 2.8.1 | [2023-03-06T22:07:39.705Z] | simctl | 1.6.10 | [2023-03-06T22:07:39.705Z] | jwt | 2.7.0 | [2023-03-06T22:07:39.705Z] | uber | 0.1.0 | [2023-03-06T22:07:39.705Z] | declarative | 0.0.20 | [2023-03-06T22:07:39.705Z] | trailblazer-option | 0.1.2 | [2023-03-06T22:07:39.705Z] | representable | 3.2.0 | [2023-03-06T22:07:39.705Z] | retriable | 3.1.2 | [2023-03-06T22:07:39.705Z] | mini_mime | 1.1.2 | [2023-03-06T22:07:39.705Z] | memoist | 0.16.2 | [2023-03-06T22:07:39.705Z] | multi_json | 1.15.0 | [2023-03-06T22:07:39.705Z] | os | 1.1.4 | [2023-03-06T22:07:39.705Z] | signet | 0.17.0 | [2023-03-06T22:07:39.705Z] | googleauth | 1.3.0 | [2023-03-06T22:07:39.705Z] | httpclient | 2.8.3 | [2023-03-06T22:07:39.705Z] | webrick | 1.6.0 | [2023-03-06T22:07:39.705Z] | google-apis-core | 0.11.0 | [2023-03-06T22:07:39.705Z] | google-apis-playcustomapp_v1 | 0.13.0 | [2023-03-06T22:07:39.705Z] | google-apis-androidpublisher_v3 | 0.34.0 | [2023-03-06T22:07:39.705Z] | google-cloud-env | 1.6.0 | [2023-03-06T22:07:39.705Z] | google-cloud-errors | 1.3.1 | [2023-03-06T22:07:39.705Z] | google-cloud-core | 1.6.0 | [2023-03-06T22:07:39.705Z] | google-apis-iamcredentials_v1 | 0.17.0 | [2023-03-06T22:07:39.705Z] | google-apis-storage_v1 | 0.19.0 | [2023-03-06T22:07:39.705Z] | rake | 13.0.1 | [2023-03-06T22:07:39.705Z] | digest-crc | 0.6.4 | [2023-03-06T22:07:39.705Z] | google-cloud-storage | 1.44.0 | [2023-03-06T22:07:39.705Z] | emoji_regex | 3.2.3 | [2023-03-06T22:07:39.705Z] | jmespath | 1.6.2 | [2023-03-06T22:07:39.705Z] | aws-partitions | 1.720.0 | [2023-03-06T22:07:39.705Z] | aws-eventstream | 1.2.0 | [2023-03-06T22:07:39.705Z] | aws-sigv4 | 1.5.2 | [2023-03-06T22:07:39.705Z] | aws-sdk-core | 3.170.0 | [2023-03-06T22:07:39.705Z] | aws-sdk-kms | 1.63.0 | [2023-03-06T22:07:39.705Z] | aws-sdk-s3 | 1.119.1 | [2023-03-06T22:07:39.705Z] | uri | 0.10.0 | [2023-03-06T22:07:39.705Z] | bundler | 2.4.6 | [2023-03-06T22:07:39.705Z] | forwardable | 1.3.1 | [2023-03-06T22:07:39.705Z] | logger | 1.4.2 | [2023-03-06T22:07:39.705Z] | cgi | 0.1.0 | [2023-03-06T22:07:39.705Z] | date | 3.0.0 | [2023-03-06T22:07:39.705Z] | timeout | 0.1.0 | [2023-03-06T22:07:39.705Z] | stringio | 0.1.0 | [2023-03-06T22:07:39.705Z] | ipaddr | 1.2.2 | [2023-03-06T22:07:39.705Z] | openssl | 2.1.2 | [2023-03-06T22:07:39.705Z] | zlib | 1.1.0 | [2023-03-06T22:07:39.705Z] | mutex_m | 0.1.0 | [2023-03-06T22:07:39.705Z] | ostruct | 0.2.0 | [2023-03-06T22:07:39.705Z] | strscan | 1.0.3 | [2023-03-06T22:07:39.705Z] | io-console | 0.5.3 | [2023-03-06T22:07:39.705Z] | delegate | 0.1.0 | [2023-03-06T22:07:39.705Z] | fileutils | 1.4.1 | [2023-03-06T22:07:39.705Z] | etc | 1.1.0 | [2023-03-06T22:07:39.705Z] | singleton | 0.1.0 | [2023-03-06T22:07:39.705Z] | open3 | 0.1.0 | [2023-03-06T22:07:39.705Z] | yaml | 0.1.0 | [2023-03-06T22:07:39.705Z] | psych | 3.1.0 |

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 5
  • Comments: 23 (2 by maintainers)

Most upvoted comments

It happens randomly to our apps. Sometimes passes but today from 5 apps 3 received that error with redeploy it works but it is not a solution I guess.

Also seeing this, it’s intermittent.

Hi,

Same thing here +++

Still failing, no line break issue for us, things just stopped working.On 13 Dec 2023, at 2:49 am, MaryKilduff68 @.***> wrote: Hello, We were able to resolve our issue. There were two causes to our problem but the one that we couldn’t find documentation for was line breaks in the key. There was no documentation necessarily for this that came up so wanted to post this here. Ensure that when you paste the key you’ve downloaded that you adjust the formatting such that you use newline characters instead of linebreaks. For the avoidance of all doubt, the whole key including the begin and end lines should be on a single line. Not sure if this will solve anyone elses issue but wanted to post just in case! The other issue was that was an unknown change to our provisioning profiles that went unnoticed.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

Same here, Apple has issues. We just retry the step when it fails.