ittybittyapps / appstoreconnect-cli

An easy to use command-line tool for interacting with the Apple AppStore Connect API
MIT License
172 stars 17 forks source link

Error: issuerNotProvided #234

Closed mohamed-hmd closed 3 years ago

mohamed-hmd commented 3 years ago

🌎 Environment

💬 Description

Error: issuerNotProvided

adamjcampbell commented 3 years ago

@mohamed-hmd this error occurs when the APPSTORE_CONNECT_ISSUER_ID environment variable or the --api-issuer argument is not provided. Can you please confirm you have set up Authentication as per the README instructions?

mohamed-hmd commented 3 years ago

yes and Please Send me an email so I can message you

mohamed-hmd commented 3 years ago

Error: Unknown option '--api-issuer'

adamjcampbell commented 3 years ago

@mohamed-hmd it'd be good to get a little more information about what command you tried, are you able to provide the full command you attempted with the auth values redacted?

mohamed-hmd commented 3 years ago

asc --api-42ddee7a-ْْxxx-xxxx-xxxx-xxxxxxxxxxxx Can you send the correct command

DechengMa commented 3 years ago

asc --api-42ddee7a-ْْxxx-xxxx-xxxx-xxxxxxxxxxxx Can you send the correct command

Hi @mohamed-hmd, there are three ways to input your credentials

  1. Through environment variables

Please paste this in your terminal, before using asc

export APPSTORE_CONNECT_ISSUER_ID=YOUR_APPSTORE_CONNECT_ISSUER_ID
export APPSTORE_CONNECT_API_KEY_ID=YOUR_APPSTORE_CONNECT_API_KEY_ID
export APPSTORE_CONNECT_API_KEY=YOUR_APPSTORE_CONNECT_API_KEY

Example:

export APPSTORE_CONNECT_ISSUER_ID=123456-8050-4f65-ac98-fb6ff65fb4f4
export APPSTORE_CONNECT_API_KEY_ID=ABC12SABCD
export APPSTORE_CONNECT_API_KEY=ABCDAgEAMBMGByqGSM49AgABCqGSM49AbCDBHkwdwIBAQQgOPNU0MmtWkdoIfgtMOknlQYlLe/ABC++loClNTGyMKegCgYIKoZIzj0DAQabCDEFGHRBdW2gywF71lMift7bKGHvVxdmX47G5zhY4yZn8gMkylVDJU+ABCd123PqT+aA9bcCoXDEFqN0goT/ABUC12345

then

swift run asc users list 


  1. Through asc command line options:

Input key as environment variables

export APPSTORE_CONNECT_API_KEY=ABCDAgEAMBMGByqGSM49AgABCqGSM49AbCDBHkwdwIBAQQgOPNU0MmtWkdoIfgtMOknlQYlLe/ABC++loClNTGyMKegCgYIKoZIzj0DAQabCDEFGHRBdW2gywF71lMift7bKGHvVxdmX47G5zhY4yZn8gMkylVDJU+ABCd123PqT+aA9bcCoXDEFqN0goT/ABUC12345

then

asc users list --api-issuer YOUR_APPSTORE_CONNECT_ISSUER_ID --api-key-id YOUR_APPSTORE_CONNECT_API_KEY_ID


  1. Through file

Put the downloaded AuthKey_YOUR_APPSTORE_CONNECT_API_KEY_ID.p8 file into one of these four directories

Then

swift run asc users list  --api-issuer YOUR_APPSTORE_CONNECT_ISSUER_ID --api-key-id YOUR_APPSTORE_CONNECT_API_KEY_ID 
mohamed-hmd commented 3 years ago

How do I do it through asc command line options: Input key as environment variables like this : export APPSTORE_CONNECT_API_KEY=ABCDAgEAMBMGByqGSM49AgABCqGSM49AbCDBHkwdwIBAQQgOPNU0MmtWkdoIfgtMOknlQYlLe/ABC++loClNTGyMKegCgYIKoZIzj0DAQabCDEFGHRBdW2gywF71lMift7bKGHvVxdmX47G5zhY4yZn8gMkylVDJU+ABCd123PqT+aA9bcCoXDEFqN0goT/ABUC12345

but When I send this command

asc users list --api-issuer YOUR_APPSTORE_CONNECT_ISSUER_ID --api-key-id YOUR_APPSTORE_CONNECT_API_KEY_ID

Get:

Error: Request failed with status code 401 and response { "errors": [{ "status": "401", "code": "NOT_AUTHORIZED", "title": "Authentication credentials are missing or invalid.", "detail": "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" }] }).

DechengMa commented 3 years ago

How do I do it through asc command line options: Input key as environment variables like this : export APPSTORE_CONNECT_API_KEY=ABCDAgEAMBMGByqGSM49AgABCqGSM49AbCDBHkwdwIBAQQgOPNU0MmtWkdoIfgtMOknlQYlLe/ABC++loClNTGyMKegCgYIKoZIzj0DAQabCDEFGHRBdW2gywF71lMift7bKGHvVxdmX47G5zhY4yZn8gMkylVDJU+ABCd123PqT+aA9bcCoXDEFqN0goT/ABUC12345

but When I send this command

asc users list --api-issuer YOUR_APPSTORE_CONNECT_ISSUER_ID --api-key-id YOUR_APPSTORE_CONNECT_API_KEY_ID

Get:

Error: Request failed with status code 401 and response { "errors": [{ "status": "401", "code": "NOT_AUTHORIZED", "title": "Authentication credentials are missing or invalid.", "detail": "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 you need to replace YOUR_APPSTORE_CONNECT_ISSUER_ID with your really Issuer Id like 123456-8050-4f65-ac98-fb6ff65fb4f4, same as the YOUR_APPSTORE_CONNECT_API_KEY_ID

mohamed-hmd commented 3 years ago

How do I do it through asc command line options: Input key as environment variables like this : export APPSTORE_CONNECT_API_KEY=ABCDAgEAMBMGByqGSM49AgABCqGSM49AbCDBHkwdwIBAQQgOPNU0MmtWkdoIfgtMOknlQYlLe/ABC++loClNTGyMKegCgYIKoZIzj0DAQabCDEFGHRBdW2gywF71lMift7bKGHvVxdmX47G5zhY4yZn8gMkylVDJU+ABCd123PqT+aA9bcCoXDEFqN0goT/ABUC12345 but When I send this command asc users list --api-issuer YOUR_APPSTORE_CONNECT_ISSUER_ID --api-key-id YOUR_APPSTORE_CONNECT_API_KEY_ID Get: Error: Request failed with status code 401 and response { "errors": [{ "status": "401", "code": "NOT_AUTHORIZED", "title": "Authentication credentials are missing or invalid.", "detail": "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 you need to replace YOUR_APPSTORE_CONNECT_ISSUER_ID with your really Issuer Id like 123456-8050-4f65-ac98-fb6ff65fb4f4, same as the YOUR_APPSTORE_CONNECT_API_KEY_ID

I did it and it didn't work for me

DechengMa commented 3 years ago

How do I do it through asc command line options: Input key as environment variables like this : export APPSTORE_CONNECT_API_KEY=ABCDAgEAMBMGByqGSM49AgABCqGSM49AbCDBHkwdwIBAQQgOPNU0MmtWkdoIfgtMOknlQYlLe/ABC++loClNTGyMKegCgYIKoZIzj0DAQabCDEFGHRBdW2gywF71lMift7bKGHvVxdmX47G5zhY4yZn8gMkylVDJU+ABCd123PqT+aA9bcCoXDEFqN0goT/ABUC12345 but When I send this command asc users list --api-issuer YOUR_APPSTORE_CONNECT_ISSUER_ID --api-key-id YOUR_APPSTORE_CONNECT_API_KEY_ID Get: Error: Request failed with status code 401 and response { "errors": [{ "status": "401", "code": "NOT_AUTHORIZED", "title": "Authentication credentials are missing or invalid.", "detail": "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 you need to replace YOUR_APPSTORE_CONNECT_ISSUER_ID with your really Issuer Id like 123456-8050-4f65-ac98-fb6ff65fb4f4, same as the YOUR_APPSTORE_CONNECT_API_KEY_ID

I did it and it didn't work for me

There might be something wrong with you key I think, can you double-check your credentials? Or give method 1 a shot? FYI, when you input the key as environment variables, you need to remove the -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY----- and these line breaks from the p8 file and concatenate these as a whole string

mohamed-hmd commented 3 years ago

The method did not work for me I am in dire need of this tool So please can you make a video tutorial of how to install and run the tool, and I will pay for that

DechengMa commented 3 years ago

The method did not work for me I am in dire need of this tool So please can you make a video tutorial of how to install and run the tool, and I will pay for that

I believe the problem is relevant to your credentials, If you have trouble concatenating the key, can you try place the AuthKey_ABCD1234.p8 file in the required directory, and run

asc users list --api-issuer YOUR_APPSTORE_CONNECT_ISSUER_ID --api-key-id YOUR_APPSTORE_CONNECT_API_KEY_ID

again

mohamed-hmd commented 3 years ago

The method did not work for me I am in dire need of this tool So please can you make a video tutorial of how to install and run the tool, and I will pay for that

I believe the problem is relevant to your credentials, If you have trouble concatenating the key, can you try place the AuthKey_ABCD1234.p8 file in the required directory, and run

asc users list --api-issuer YOUR_APPSTORE_CONNECT_ISSUER_ID --api-key-id YOUR_APPSTORE_CONNECT_API_KEY_ID

again

the same problem So please please can you make a video tutorial of how to install and run the tool, and I will pay for that

mohamed-hmd commented 3 years ago

The method did not work for me I am in dire need of this tool So please can you make a video tutorial of how to install and run the tool, and I will pay for that

I believe the problem is relevant to your credentials, If you have trouble concatenating the key, can you try place the AuthKey_ABCD1234.p8 file in the required directory, and run

asc users list --api-issuer YOUR_APPSTORE_CONNECT_ISSUER_ID --api-key-id YOUR_APPSTORE_CONNECT_API_KEY_ID

again

I changed the certificate and all the information AuthKey_ABCD1234.p8 issuer --api-key-id

but same problem

Error: Request failed with status code 401 and response { "errors": [{ "status": "401", "code": "NOT_AUTHORIZED", "title": "Authentication credentials are missing or invalid.", "detail": "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" }] }).

adamjcampbell commented 3 years ago

@mohamed-hmd

Can you please confirm that you have logged into the App Store Connect web portal and created a token for yourself with the correct permissions?

This tool is built on top of the App Store Connect API so if you are able to successfully authenticate with that you should be able to use this tool.

As you can see you are getting a 401 NOT_AUTHORIZED error which means there is an issue with your credentials. Documentation for creating these credentials is documented by Apple here: https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api

There is also a lot of information on using the API in general here: https://developer.apple.com/documentation/appstoreconnectapi

Finally there are WWDC sessions that show how to use the API e.g. https://developer.apple.com/videos/play/wwdc2018/303/ (they touch on authentication from around the 28 minute mark)

I would suggest that you watch this WWDC session and read some of the documentation to confirm that you can hit the API with a REST client or even a script as they do in the WWDC session before trying the CLI tool.

mohamed-hmd commented 3 years ago

Thanks to everyone I have worked successfully

But I have another question

I want command To add udid

adamjcampbell commented 3 years ago

Closing this issue since it is solved @mohamed-hmd

For adding a device you would be talking about this API: https://developer.apple.com/documentation/appstoreconnectapi/register_a_new_device Which for asc maps to: asc devices register

Please lean on the --help flag to try and learn the usage of the command:

$ asc devices register --help

OVERVIEW: Register a new device for app development.

USAGE: asc devices register [--api-issuer <uuid>] [--api-key-id <keyid>] [--csv] [--json] [--table] [--yaml] [--verbose] <udid> <name> <platform>

ARGUMENTS:
  <udid>                  The UDID of the device to register.
  <name>                  The name of the device to register.
  <platform>              The platform of the device to register [ios, mac_os,
                          tv_os, watch_os].

OPTIONS:
  --api-issuer <uuid>     An AppStore Connect API Key issuer ID. (default:
                          @env:APPSTORE_CONNECT_ISSUER_ID)
        The value for this option can be obtained from the AppStore Connect
        portal and takes the form of a UUID.

        If not specified on the command line this value will be read from the
        environment variable APPSTORE_CONNECT_ISSUER_ID.
  --api-key-id <keyid>    An AppStoreConnect API Key ID. (default:
                          @env:APPSTORE_CONNECT_API_KEY_ID)
        The value for this option can be obtained from the AppStore Connect
        portal and takes the form of an 10 character alpha-numeric identifier,
        eg. 7MM5YSX5LS

        If not specified on the command line the value of this option will be
        read from the environment variable APPSTORE_CONNECT_API_KEY_ID.

        The environment will be searched for key with the name of
        APPSTORE_CONNECT_API_KEY. The contents of this environment key are
        expected to be a PKCS 8 (.p8) formatted private key associated with
        this Key ID.

        If the APPSTORE_CONNECT_API_KEY environment variable is empty, in the
        incorrect format, or not found then the following directories will be
        searched in sequence for a private key file with the name of
        'AuthKey_<keyid>.p8': ./private_keys, ~/private_keys, ~/.private_keys
        and ~/.appstoreconnect/private_keys.
  --csv/--json/--table/--yaml
                          Display results in specified format. (default: table)
  -v, --verbose           Display extra messages as command is running.
  -h, --help              Show help information.