Codemagic APP_STORE_CONNECT_PRIVATE_KEY Provided value is not valid
make sure you downloaded the private API key from App Store Connect in .p8
format and copied the entire contents when paste into environment variable value field.
RainChaser
Updated on January 01, 2023Comments
-
RainChaser over 1 year
I'm trying to sign the iOS build on Codemagic using YAML workflow. Following this document I encrypted and added the following environment variables:
- APP_STORE_CONNECT_KEY_IDENTIFIER
- APP_STORE_CONNECT_ISSUER_ID
- APP_STORE_CONNECT_PRIVATE_KEY
- CERTIFICATE_PRIVATE_KEY
On running the workflow I'm getting error Provided value "VALUE of APP_STORE_CONNECT_PRIVATE_KEY" is not valid. What to make this env variable value valid? I also tried adding base64 encoding for this value, but it still shows the same error.
Here's my codemagic.yaml file:
workflows: ios-workflow: name: iOS Workflow # instance_type: mac_mini max_build_duration: 120 environment: groups: - store vars: XCODE_WORKSPACE: "Runner.xcworkspace" XCODE_SCHEME: "Runner" BUNDLE_ID: "*MY_BUNDLE_ID*" flutter: stable xcode: latest cocoapods: default scripts: - name: Set up keychain to be used for codesigning using Codemagic CLI 'keychain' command script: | keychain initialize - name: Fetch signing files script: | # Failing command with invalid APP_STORE_CONNECT_PRIVATE_KEY **app-store-connect fetch-signing-files $BUNDLE_ID --type IOS_APP_STORE --create** - name: Use system default keychain script: | keychain add-certificates
Error:
File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/cli_app.py", line 201, in invoke_cli CliApp._running_app = cls._create_instance(parser, args) File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/cli_app.py", line 130, in _create_instance instance = cls.from_cli_args(cli_args) File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/tools/app_store_connect.py", line 116, in from_cli_args private_key_argument = AppStoreConnectArgument.PRIVATE_KEY.from_args(cli_args) File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/argument/argument.py", line 55, in from_args return self.value.type.from_environment_variable_default() File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/argument/typed_cli_argument.py", line 42, in from_environment_variable_default
return cls(os.environ[cls.environment_variable_key], from_environment=True) File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/argument/typed_cli_argument.py", line 33, in init self.value: T = self._parse_value() File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/argument/typed_cli_argument.py", line 129, in _parse_value return super()._parse_value() File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/argument/typed_cli_argument.py", line 57, in _parse_value return self._apply_type(value) File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/argument/typed_cli_argument.py", line 52, in _apply_type raise argparse.ArgumentTypeError(f'Provided value "{value}" is not valid') argparse.ArgumentTypeError: Provided value "VALUE of APP_STORE_CONNECT_PRIVATE_KEY" is not valid -
RainChaser over 2 yearsYes, I'm pasting the entire file along with -----BEGIN PRIVATE KEY-----....-----END PRIVATE KEY-----. Still facing the same error.
-
RainChaser over 2 yearsCorrection: I just put the entire key and it worked. Thanks for your input.