Reputation: 87
what issue am facing in Azure Console:
*"Looking for related GitHub issues on fastlane/fastlane... [!] The request could not be completed because: 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 API Key JSON created at: /Users/runner/work/_temp/appstoreconnect_api_key.json"
Below i am sharing yaml
task: Bash@3 displayName: Create API Key JSON File for Fastlane inputs: targetType: 'inline' script: | # Define variables API_KEY_PATH=$(Agent.TempDirectory)/AuthKey.p8 API_KEY_JSON_PATH=$(Agent.TempDirectory)/appstoreconnect_api_key.json
PRIVATE_KEY=$(awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' $API_KEY_PATH)
# Convert the AuthKey.p8 into JSON format required by Fastlane
echo '{
"key_id": "'"${APP_STORE_CONNECT_API_KEY_ID}"'",
"issuer_id": "'"${APP_STORE_CONNECT_API_ISSUR_ID}"'",
"key": "'"${PRIVATE_KEY}"'"
}' > $API_KEY_JSON_PATH
# Output the path to the generated JSON file for Fastlane
echo "Contents of the API Key JSON:"
cat $API_KEY_JSON_PATH
- task: Bash@3
displayName: Upload to TestFlight using Fastlane
inputs:
targetType: 'inline'
script: |
# Set environment variables
API_KEY_JSON_PATH=$(Agent.TempDirectory)/appstoreconnect_api_key.json
# Upload to TestFlight using Fastlane
fastlane pilot upload \
--api_key_path $API_KEY_JSON_PATH \
--app_identifier "XXXXXXXXXXXXXXX" \
--team_id $(TEAM_ID) \
--ipa $(build.artifactstagingdirectory)/build/*.ipa
echo "API Key JSON created at: $API_KEY_JSON_PATH"
These two script i have shared related to issues. I checked Key_ID, ISSUER_ID, .AuthKey.p8 files, these are credencials corrects.And also set in azure portal env. Fastlane is using 2.226.
Thanks.
Upvotes: 0
Views: 38
Reputation: 8468
It appears you are directly copying the content from AuthKey.p8 as the key value.
You need to re-encoded the content of the .p8 file to get the base64 key. please refer to the link here and here for the details(copied and pasted below).
To convert your key to base64, put it in a txt file and run one of this command below, depending on your OS. You will get a file containing the base64 string that represent your API key.
Windows:
certutil -encode data.txt tmp.b64 && findstr /v /c:- tmp.b64 > data.b64 && del tmp.b64
Mac:
base64 -i data.txt -o data.b64
Ubuntu:
base64 data.txt > data.b64
In addition, the fastlane doc introduced official DevOps extension Apple App Store which uses fastlane. You can also use the task which support 3 different authentication methods(sample here).
Upvotes: 0