> ## Documentation Index
> Fetch the complete documentation index at: https://auth0.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Build a Self-Service Account Security Interface with My Account API on iOS

> Describes how to use Universal Components to build self-service account security interfaces with Auth0's My Account API on iOS.

export const ReleaseStageNotice = ({feature, stage, plans, contact, terms}) => {
  const stageTextMap = {
    "beta": "Beta",
    "ea": "Early Access"
  };
  const stageText = stageTextMap[stage] || "a product release stage";
  const prsLink = "/docs/troubleshoot/product-lifecycle/product-release-stages";
  const linkify = (text, url) => {
    return <a href={url} target="_blank" rel="noreferrer" class="link">{text}</a>;
  };
  const includeDetails = (plans, contact, terms) => {
    const hasDetails = terms || plans || contact;
    if (!hasDetails) return null;
    return <span data-as="p">
            {plans && <>This feature is available for {linkify(`${plans} plans`, "https://auth0.com/pricing")}. </>}
            {contact && "To participate, contact " + contact + ". "}
            {terms && <>By using this feature, you agree to the applicable Free Trial terms in Okta's {linkify("Master Subscription Agreement", "https://www.okta.com/legal")}.</>}
        </span>;
  };
  return <Warning>
            <span data-as="p">
                <strong>The {feature} feature is in {linkify(stageText, prsLink)}.</strong>
            </span>

            {includeDetails(plans, contact, terms)}
        </Warning>;
};

<ReleaseStageNotice feature="Auth0 Universal Components" stage="beta" terms="true" contact="Auth0 Support" />

Auth0 Universal Components for iOS allow you to build a self-service account security UI within your [native iOS application](/docs/get-started/auth0-overview/create-applications#create-application-in-auth0).

With the `MyAccountAuthMethodsView` component, users can manage their own authentication methods — multi-factor authentication (MFA) factors, passkeys, and recovery codes — directly inside your native application, without leaving for a web browser or contacting support.

## How it works

The `MyAccountAuthMethodsView` component uses Auth0 [My Account API's authentication methods](/docs/manage-users/my-account-api#manage-authentication-methods) to render an authentication methods management UI inside your application.

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  The My Account API currently enforces low rate limits, especially on free-tier tenants. This may cause errors while using these components.
</Callout>

When an authenticated user opens their account settings screen, the [Auth0.swift](https://github.com/auth0/Auth0.swift) SDK retrieves an [access token](/docs/secure/tokens/access-tokens) scoped to the My Account API audience.

The `MyAccountAuthMethodsView` component uses the access token to call the My Account API [`/me/v1/authentication-methods`](/docs/api/myaccount/authentication-methods/get-authentication-methods) endpoints as the logged-in user, so each user can only modify their own authentication methods.

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  * The `MyAccountAuthMethodsView` component creates **end-user self-service** interfaces. End users can enroll, list, and remove every authentication method on their account: email OTP, SMS OTP, TOTP (authenticator application), push via Auth0 Guardian, passkeys, and recovery codes.

  * For **delegated admin** interfaces in which a user manages an Auth0 Organization, read [Build a Delegated Admin Interface](/docs/get-started/universal-components/web/components/build-delegated-admin).
</Callout>

## Prerequisites

### Enable Auth0 My Account API

1. Navigate to [Dashboard > Applications > APIs](https://manage.auth0.com/#/apis).
2. Select **Activate My Account API** to enable it for your tenant.

### Create the application and configure My Account API permissions

1. Navigate to [Dashboard > Applications](https://manage.auth0.com/#/applications).

2. Select **Create Application**.

3. Select **Native**.

4. Select the **Settings** tab to add the following callback URLs in the **Allowed Callback URLs**:

   ```text theme={null}
   https://YOUR_AUTH0_DOMAIN/ios/YOUR_BUNDLE_ID/callback, YOUR_BUNDLE_ID://YOUR_AUTH0_DOMAIN/ios/YOUR_BUNDLE_ID/callback
   ```

5. Add the same URls for the **Allowed Logout URLs**.

   ```text theme={null}
   https://YOUR_AUTH0_DOMAIN/ios/YOUR_BUNDLE_ID/callback, YOUR_BUNDLE_ID://YOUR_AUTH0_DOMAIN/ios/YOUR_BUNDLE_ID/callback
   ```

6. Select the **API Access** tab.

7. Select **Edit** for the **Auth0 My Account API** to add the **User-delegated Access** permissions:

   `create:me:authentication_methods`
   `read:me:authentication_methods`
   `update:me:authentication_methods`
   `delete:me:authentication_methods`

8. Select **Save** to save the permissions.

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  * The user's access token only includes permissions that were granted during login.
  * Request all four scopes to allow users to enroll, review, and remove authentication methods.
</Callout>

### Install the SDK

Use the Swift Package Manager or Carthage to install the `Auth0UniversalComponents` package.

To learn more about installation details and requirements, read [Auth0 Universal Components for iOS](/docs/get-started/universal-components/ios/ios-overview).

### Initialize the SDK

To initialize the SDK, call the `Auth0UniversalComponentsSDKInitializer.initialize(...)` method once at application start, typically in your application struct's `init`.

If your application already uses `Auth0.plist` to configure Auth0.swift, add `ClientId`, `Domain`, and `Audience` keys and call:

```swift App.swift wrap lines theme={null}
import SwiftUI
import Auth0
import Auth0UniversalComponents

@main
struct MyApp: App {
    init() {
        Auth0UniversalComponentsSDKInitializer.initialize(
            tokenProvider: CredentialsManager(authentication: Auth0.authentication())
        )
    }

    var body: some Scene {
        WindowGroup { ContentView() }
    }
}
```

Or pass the values directly in code:

```swift App.swift wrap lines theme={null}
Auth0UniversalComponentsSDKInitializer.initialize(
    domain: "YOUR_AUTH0_DOMAIN",
    clientId: "YOUR_CLIENT_ID",
    audience: "https://YOUR_AUTH0_DOMAIN/me/",
    tokenProvider: CredentialsManager(authentication: Auth0.authentication())
)
```

### Configure the token provider

Use the `TokenProvider`, which wraps the [`Auth0.swift`](https://github.com/auth0/Auth0.swift) `CredentialsManager`, to request credentials from your application.

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  Auth0 recommends using the Auth0.swift's `CredentialsManager` for production integrations. Implement a custom `TokenProvider` only if the `Auth0.swift` SDK does not meet your storage requirements.
</Callout>

To manage credentials outside the Auth0.iOS SDK's `CredentialsManager`, implement the interface directly:

```swift wrap lines theme={null}
struct AppTokenProvider: TokenProvider {
    func fetchCredentials() async throws -> Credentials {
        // Return the user's login credentials.
    }
    func storeCredentials(credentials: Credentials) {
        // Persist new or refreshed credentials.
    }
    func store(apiCredentials: APICredentials, for audience: String) {
        // Persist My Account API credentials keyed by audience.
    }
    func fetchAPICredentials(audience: String, scope: String) async throws -> APICredentials {
        // Return cached My Account API credentials, refreshing if expired.
    }
}
```

<Check>
  Users must be authenticated before you render any component. After the SDK is initialized and your `TokenProvider` protocol is wired up, add the [`MyAccountAuthMethodsView`](/docs/get-started/universal-components/ios/components/auth-methods-management) component to your settings screen to give users full MFA, passkey, and recovery-code self-service.
</Check>

## Learn more

<CardGroup cols={2}>
  <Card title="Auth Methods Management" icon="shield" href="/docs/get-started/universal-components/ios/components/auth-methods-management">
    Review the `MyAccountAuthMethodsView` component reference, supported factors, and embedded-navigation examples.
  </Card>

  <Card title="Customize style and themes" icon="palette" href="/docs/get-started/universal-components/ios/ios-theming">
    Override colors, typography, spacing, radius, and size tokens using the Auth0 design-token system.
  </Card>
</CardGroup>
