Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Generate JWT token apple connect iOS

Tags:

ios

ios7

jwt

api

I'm trying to generate a JWT token for Apple Connect but It's look like something is missing in the "Verify signature" field.

  1. From the API Apple Store Connect dashboard, I'm only able to download the "private key" name AuthKey_{kid}.p8.
  2. From https://jwt.io/, I select the "ALGORITHM" as "ES256" then two field appears in the "SIGNATURE" section : a) Public key or certificate b) Private key or certificate (AuthKey_{kid}.p8)

Issue : - I do have the "Invalid Signature" message displaying ... - I don't have any idea where to find the "Public key or cerficate"

I'm following these docs : - https://developer.apple.com/documentation/appstoreconnectapi/generating_tokens_for_api_requests - https://medium.com/xcblog/generating-jwt-tokens-for-app-store-connect-api-2b2693812a35

Do you have any idea how to fix find the "Public key"?

Thank you for your help,

like image 333
CHAULVET Chris Avatar asked Jan 31 '19 13:01

CHAULVET Chris


People also ask

How do I create a JWT token for the App Store?

Use the private key associated with the key ID you specified in the header to sign the token. Regardless of the programming language you’re using with the App Store Connect API, there are a variety of open source libraries available online for creating and signing JWT tokens.

What if I have more than one JWT API key?

If you have more than one API key, use the key ID of the same private key that you use to sign the JWT. Here’s an example of a JWT header: The JWT payload contains information specific to the App Store Connect APIs, such as issuer ID and expiration time. Use the following fields and values in the JWT payload:

What is an App Store Connect web token?

JSON Web Tokens are JSON payloads encoded in Base64 and signed with your private key for their transmission to the App Store Connect API server. You can create your token with any text editor.

How do I Find my JWT issuer ID?

(Optional) To get your issuer ID, log in to App Store Connect and: Select Users and Access, then Select the API Keys tab. The issuer ID appears near the top of the page. To copy the issuer ID, click Copy next to the ID. Here’s an example of a JWT payload:


1 Answers

The .p8 file includes the private and public keys. You need to extract those using OpenSSL.

To get the private key:

$ openssl ec -in AuthKey.p8 -out AuthKey_private.p8

To get the public key:

$ openssl ec -in AuthKey.p8 -pubout -out AuthKey_public.p8

Using keys generated via these commands got the signature verified on jwt.io.

like image 186
Abdullah Malik Avatar answered Nov 14 '22 21:11

Abdullah Malik