Two different redirects
Two URLs in this flow are both called a redirect, and they are not the same thing.
The provider redirect URI is how Google or Apple hands the user back to Portal,
and it is covered in Google OAuth and
Apple OAuth. Everything below is about
the second one.
Supported forms
An App Link or Universal Link is not a separate kind of allow-list entry. To
Portal it is an ordinary HTTPS URL; what routes it to your app instead of a
browser is the association file you host on that domain
(
assetlinks.json on Android, apple-app-site-association on iOS). Portal
appends its parameters the same way either way.
Custom schemes are valid allow-list entries. If you are integrating a mobile
app, register the same custom scheme URL you will pass to the SDK — you do not
need to host a web page to complete a sign-in.
How matching works
Portal compares your redirect URL against the allow list by exact string comparison. There are no wildcards and no path prefixes.
A request whose
redirectUrl is not on the list is rejected with a 401. This
is what stops someone who has your Auth Environment ID from sending your users,
and their sign-in tokens, to a site they control. On the OAuth path the check
runs twice: once when the sign-in starts and again when the provider calls back.
Use one string everywhere
The same redirect URL has to appear, byte for byte, in up to three places.- The dashboard. The Redirect URLs allow list under Authentication > Configure. See Enable authentication.
- Your SDK configuration.
redirectUrlonPortalAuth(iOS, Android, React Native and Flutter) orclientAuth(Web). - Your native app registration. On mobile only: the URL scheme in
Info.plistand the intent filter inAndroidManifest.xml.
- Dashboard and SDK disagree — the sign-in never starts. You get a
401from the call that begins the flow. - SDK and native registration disagree — the sign-in completes, but the redirect never reaches your app. Nothing throws; the user is left in the browser.
What Portal appends
Portal appends its parameters to your redirect URL, using? or & depending
on whether your URL already has a query string.
token, the SDKs read
the last occurrence, which is always the one Portal appended.
Grants are single use
Thetoken parameter is a grant: proof that a sign-in completed. It is
short-lived and single use, and exchanging it spends it. Reading which email
address a magic link signs in to doesn’t spend it.
Once a grant has been exchanged or has expired, the user has to sign in again.
There is no way to refresh one.
Your app can show the user who a magic link signs them in as before exchanging
its grant. A Google or Apple grant is bound to the code verifier of the sign-in
that produced it, so it can only be exchanged in the app install or browser tab
that started that sign-in. The Client Auth SDKs, except Flutter, also cancel a
sign-in in progress 15 minutes after it started.
When a sign-in fails
A redirect that carries atoken can still fail when your app uses it, so your
app needs an error path on the lookup and the exchange, not just on the URL.
Each SDK reports these failures through its own errors. See the error handling
section of each SDK’s
Client Auth guide.
A redirect can arrive twice
Operating systems re-deliver deep links, and a browser can reload a callback page. Because a grant is spent on first use, a second delivery of the same redirect cannot produce a second session. Route every redirect through exactly one handler in your app. Depending on the SDK and the method that completes the sign-in, handling the same redirect again on the instance that completed it may return the result of the first exchange, or may fail. Don’t rely on either: after the app restarts, the page reloads, or the session ends, a repeated redirect fails because its grant has already been spent. On launch, restore the stored session instead of handling the redirect again.Register the redirect in your app
- Android
- iOS
- Web
- React Native
- Flutter
Register the scheme and host of your redirect URL in the manifest, so the OS
delivers the redirect to your app as a deep link.For Both activity attributes matter:
myapp://auth/callback, add an intent filter to the activity that
should receive it:android:exported="true" is required on
Android 12 and later for an activity with an intent filter, and
android:launchMode="singleTask" delivers the redirect to the activity
already running instead of starting a second instance.See Client Auth for the code that
receives it.Client Auth is available in the Portal Android, iOS, React Native, Flutter, and Web SDKs. If
you are integrating on another platform, you can drive the same flow against the
Authentication API directly.
Next steps
Android Client Auth
Receive the redirect and turn it into a session in an Android app.
iOS Client Auth
Receive the redirect and turn it into a session in an iOS app.
React Native Client Auth
Receive the redirect and turn it into a session in a React Native app.
Flutter Client Auth
Receive the redirect and turn it into a session in a Flutter app.
Web Client Auth
Build a callback route and complete a sign-in in a web app.