Skip to content

Class

JWTGenerator

Generates ES256-signed JWTs for App Store Connect API authentication.

actor JWTGenerator

Overview

Tokens are cached and reused until near expiry (default: 15 min lifetime). Supports both Team API Keys and Individual API Keys.

Lifetime guidance:

  • Standard operations: use the default 15-minute lifetime.

  • Long-lived GET-only tokens (e.g. for read-only CI dashboards): pass lifetime: .months(6) together with a scope array. Apple only allows extended lifetimes for scoped tokens on select read endpoints.

Usage

let generator = JWTGenerator(
    keyID: "2X9R4HXF34",
    issuerID: "57246542-96fe-1a63-e053-0824d011072a",
    privateKey: p8KeyData
)
// Standard short-lived token
let token = try await generator.generateToken()

// Long-lived scoped read token (up to 6 months)
let readToken = try await generator.generateToken(
    scope: ["GET /v1/apps"],
    lifetime: .months(6)
)

Topics

Instance Methods

Type Properties

Default Implementations

Relationships

Conforms To

  • Swift.Sendable
  • Swift.SendableMetatype
  • _Concurrency.Actor