Creating a HaapiAccessor#

HaapiAccessor is the SDK Layer’s entry point. It wraps HaapiManager (flow stepping) and OAuthTokenManager (OAuth lifecycle) and selects the right access strategy — attestation or Dynamic Client Registration fallback — based on device capabilities and your configuration. Build one per authentication flow.

Construction#

HaapiAccessorBuilder is the recommended constructor on iOS:

let baseURL = URL(string: "https://idsvr.example.com")!

let haapiConfiguration = HaapiConfiguration(
    name: "ios-client",
    clientId: "haapi-ios-client",
    baseURL: baseURL,
    tokenEndpointURL: URL(string: "/oauth/v2/oauth-token", relativeTo: baseURL)!,
    authorizationEndpointURL: URL(string: "/oauth/v2/oauth-authorize", relativeTo: baseURL)!,
    appRedirect: "app://haapi",
    httpHeadersProvider: nil,
    authorizationParametersProvider: nil
)

let haapiAccessor = HaapiAccessorBuilder(haapiConfiguration)
    .buildForHaapi()

let haapiManager = haapiAccessor.haapiManager
let oAuthTokenManager = haapiAccessor.oAuthTokenManager

Dispose of the accessor via haapiAccessor.close() before re-creating it.

Access Patterns#

The builder/factory exposes multiple construction methods. Pick the one that matches the operation you are about to perform:

  • .buildForHaapi() — returns a HaapiAccessor with both managers. Use for a full authorization flow.
  • .buildForOAuth() — returns an OAuthAccessor with only OAuthTokenManager. Use for token-only operations (refresh, revoke) — for example, from an App Extension that cannot run the full HAAPI flow.

Was this helpful?