Skip to content

Add configurable base URL and JWT scope claim support#340

Open
jsj wants to merge 1 commit intoAvdLee:masterfrom
jsj:feature/configurable-base-url-and-jwt-scope
Open

Add configurable base URL and JWT scope claim support#340
jsj wants to merge 1 commit intoAvdLee:masterfrom
jsj:feature/configurable-base-url-and-jwt-scope

Conversation

@jsj
Copy link
Copy Markdown

@jsj jsj commented Apr 2, 2026

Motivation

The App Store Connect API base URL is currently hardcoded in Request<Response>, preventing use of the SDK's authentication and request infrastructure with related Apple APIs that share the same JWT-based auth but live at different base URLs.

The primary use case is the Apple Notary API v2, which lives at appstoreconnect.apple.com/notary/v2/ (vs api.appstoreconnect.apple.com) and requires a scope claim in the JWT payload. Today, anyone wanting to use the Notary API alongside the ASC API must build an entirely separate JWT + HTTP client despite sharing the same credentials.

Changes

Request<Response> — configurable baseURL

  • Promotes baseURL from a hardcoded internal computed property to a public stored property with a default of the standard ASC API URL
  • Adds a defaultBaseURL static computed property for reference
  • Fully backward compatible — all existing code compiles without changes since the new baseURL parameter defaults to the current value

JWT — optional scope claim

  • Adds an optional scope: [String]? parameter to JWT.init (defaults to nil)
  • When nil, the claim is omitted entirely from the encoded payload (standard Codable behavior for optionals)
  • When set (e.g. ["/notary/v2"]), it's included in the JWT payload as required by Apple's Notary API authentication docs

Usage

// Existing usage — no changes required
let request = APIEndpoint.v1.apps.get()
let response = try await provider.request(request)

// New: request with custom base URL
var request = APIEndpoint.v1.someEndpoint.get()
request.baseURL = URL(string: "https://appstoreconnect.apple.com")!

// New: JWT with scope for Notary API
let jwt = JWT(keyIdentifier: "KEY_ID", issuerIdentifier: "ISSUER_ID", expireDuration: 600, scope: ["/notary/v2"])

Testing

  • All 22 existing tests pass
  • No changes to generated OpenAPI code
  • No breaking API changes

🤖 Generated with Claude Code

@jsj jsj requested a review from AvdLee as a code owner April 2, 2026 00:35
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 48796b9d33

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jsj jsj force-pushed the feature/configurable-base-url-and-jwt-scope branch from 48796b9 to 704c1fc Compare April 2, 2026 00:39
The App Store Connect API base URL is currently hardcoded in
`Request<Response>`, which prevents using the SDK's authentication and
request infrastructure with related Apple APIs that share the same
JWT-based auth but live at different base URLs (e.g. the Notary API at
`appstoreconnect.apple.com/notary/v2/`).

This change:

- Promotes `baseURL` from a hardcoded internal computed property to a
  public stored property on `Request<Response>` with a default of the
  standard ASC API URL. Fully backward compatible — existing code
  compiles without changes.

- Adds an optional `scope` parameter to `JWT` for APIs that require a
  restricted scope claim in the token payload (e.g. the Notary API
  requires `scope: ["/notary/v2"]`). Defaults to `nil`, which omits
  the claim entirely, preserving existing behavior.
@jsj jsj force-pushed the feature/configurable-base-url-and-jwt-scope branch from 704c1fc to 9e940fb Compare April 2, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant