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
- [ x ] Updated fastlane to the latest version. Version 2.212.1
- [ x ] I read the Contribution Guidelines
- [ x ] I read docs.fastlane.tools
- [ x ] I searched for existing GitHub issues Checked issues #18100, #19072 and #20270
- [ x ] I changed key durations to value of 100, 500, 1150, 1200
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]: [33mGet started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile[0m [2023-03-06T22:07:39.706Z] [22:07:18]: [32m-------------------[0m [2023-03-06T22:07:39.706Z] [22:07:18]: [32m— Step: debug —[0m [2023-03-06T22:07:39.706Z] [22:07:18]: [32m-------------------[0m [2023-03-06T22:07:39.706Z] [32mLane Context[0m [2023-03-06T22:07:39.706Z] {} [2023-03-06T22:07:39.706Z] [22:07:20]: [33mGet started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile[0m [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]: [31mError finding relevant GitHub issues: undefined method
map' for nil:NilClass[0m [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:inhandle_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][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]`./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]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 4 years ago
- Reactions: 9
- Comments: 68 (3 by maintainers)
I can confirm that this error is happening on version 2.224.0 but not in 2.223.1.
Fastlane team be like -> 😴😴😴🥱🥱🥱😪😪😪
We have the same problem with the version 2.225.0 while call upload_to_testflight() it gives: “Authentication credentials are missing or invalid. - Provide a properly configured and signed bearer token, and make sure that it has not expired…”
This worked for me. Thanks!
But version 2.225.0 has the same problem here.
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.
I was able to solve the issue by using the team’s AuthKey instead of the personal developer’s key. Looks like the issue is in the
issuer_id- the personal key do not have/do not use this. Also pay attention to thein_house- it should befalsefor non-enterprise dev accounts.The configuration I’m using:
When using the json file, I’ve set
"in_house": "false"but still get the same error (for our non-enterprise account)Any update on this? I’m using fastlane 2.225.0 and it’s still happening
Temporarily reverted it back to 2.223.0 works
Make sure you haven’t set
SPACESHIP_CONNECT_API_IN_HOUSE = trueas an ENV variable; after the merge of this PR, it causes the enterprise configuration to be used.We have the same problem here, version 2.225.0 resolve the 503 error but now we can’t upload to testflight ‘“Authentication credentials are missing or invalid. - Provide a properly configured and signed bearer token, and make sure that it has not expired…”’. Spaceauth log me successfully
Also seeing this, it’s intermittent.
Cool! Make a PR?
Just solved !! The problem was a date of macOS system with incorrect timezone… so, the token was generated already expired for me !
It is not working for me regardless of the Fastlane version, it fails on both 2.223.0 and 2.225.0.
Not using the API for authentication, but the upgrade from 2.223.0 also has this error occur for us when using
upload_to_testflight()Also have the same issue with 2.224.0 using the App Store Connect API team token (json) for any fastlane commands. What’s odd is that using fastlane commands with the Enterprise account works normally
I confirm that changing “The token session duration” of the AppStore connect key to
500has patched the bug. This P8 key authenticates our app deployments with TestFlight, and it’s referenced on the Fastlile lanes.Hi Folks, I came across this issue for a month. I could addressed and fixed this issue by comment the line. https://github.com/fastlane/fastlane/blob/39ed6fed0c3cb8439238c4aec62384c59966931f/spaceship/lib/spaceship/connect_api/token.rb#L104 but on my local system or my ci/cd which updated to the latest version 2.219.0 contains the code below
I brought the file location on our ci/cd tools.
/usr/local/lib/ruby/gems/3.3.0/gems/fastlane-2.219.0/spaceship/lib/spaceship/connect_api/token.rbit would be different than mine definitely.the apple doc mentioned that you use the
iatin a payload. However, the Apple server could not verify the JWT token.when I tried to comment that line code. the solution worked out.
I hope the one folk could fix this issue as soon as possible. @MaxToyberman @pomarec @realityworks @nicklbaert
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.
This error appeared for me when I switched from Xcode 14 to 15 on GitHub Actions…
@tutudeloitte try this guide https://medium.com/@muhammedqazi/mastering-fastlane-the-ultimate-guide-to-effortless-android-and-ios-deployments-with-github-e0878c3f9529