Skip to main content

Request a scope

Start a step-up flow for a given scope. The returned challenge tells you what the server wants next — typically an OTP delivery step (verify_email or verify_sms). Code delivery is caller-driven: you pass the challenge to sendStepUpOTP when your UI is ready (see the next section).
StepUpChallenge is a value type — each caller holds its own copy, so concurrent step-up flows on a single client don’t share state. The most recent challenge is also available for diagnostics:
The challenge exposes the following fields:

Send the step-up OTP

When challenge.currentStep is verify_email or verify_sms, fire delivery by passing the challenge to sendStepUpOTP. The SDK posts to /otp and the user receives the code on the corresponding identifier.
Throws PreludeAuthError.invalidChallengeToken if challenge is blocked (no token to sign with).
Code delivery is intentionally caller-driven on every platform: the SDK doesn’t fire /otp on its own, so your UI controls timing and can expose a “Resend code” affordance by calling sendStepUpOTP again with the same challenge.

Submit an OTP step

Submit the code the user entered. The SDK signs /otp/check with a challenge-scoped DPoP proof, advances the challenge, and — when the flow reaches completed — automatically refreshes the session so the next access token carries the granted scope. When submitStepUpOTP returns a non-null next challenge whose currentStep is another OTP delivery (for example, verify_email → verify_sms), call sendStepUpOTP(next) again to fire the next code before prompting the user.

Automatic completion

When the last step is completed, the SDK:
  1. Refreshes the session with the challenge token, minting an access token that carries the granted scope. Concurrent refresh() callers piggyback on the same in-flight refresh.
  2. Clears the active step-up handle.
  3. Returns no further step from submitStepUpOTP to signal the flow is done.
After that, any protected call you make uses the scoped token automatically.
This example builds on the project from Introduction. Make sure you have a working OTP login first (OTP Login).1. Create a mock hookGo to mockerapi.com and create a mock API that returns the following JSON on POST:
Copy the generated mock URL.2. Configure step-up
3. Register the scope
4. Replace your entry file
Replace ContentView.swift:
ContentView.swift
Build and run, log in with your phone number, then tap Request transfer:write. You’ll receive a second OTP to complete the challenge. After verification, the access token will include the transfer:write scope.