Type | Description | Example |
---|---|---|
Web URL | A standard HTTPS web URL for redirecting back to web application. | https://example.com/auth |
API Endpoint | A GET API that can be used to directly handle the authentication response. | https://api.example.com/auth |
Application Deep Link | A custom scheme URL for redirecting back to a mobile application. | example://auth |
Setting Up a Redirect URI for Mobile Apps
Android
-
Defining a Deep Link in the Manifest: Start by adding intent filters in your
AndroidManifest.xml
. This tells Android how to handle URLs intended for your app. Define a custom scheme or host to ensure your app uniquely captures the redirect URL. -
Handling the Intent in an Activity: In your
MainActivity
, overrideonCreate
oronNewIntent
to handle the incoming intent. Extract the code or token from the URI:
iOS
- Configuring URL Schemes: In Xcode, go to your project settings and add a URL scheme under URL Types. This is your app’s custom URL scheme.
-
Handling Incoming URLs: Implement URL handling in your
AppDelegate
. This method is invoked when your app is asked to open a custom URL scheme:
yourcustomscheme
should be replaced with the custom URL scheme you defined.
React Native
-
Register a Custom URL Scheme:
- For Android, modify
AndroidManifest.xml
as shown in the Android section. - For iOS, configure URL Types in Xcode project settings.
- For Android, modify
-
Handling Incoming Links:
- Use the
Linking
API in React Native to handle incoming URLs. - Listen for incoming URLs and parse them to extract the
code
.
- Use the
Flutter
-
Register a Custom URL Scheme:
- For Android, modify
AndroidManifest.xml
as shown in the Android section. - For iOS, configure URL Types in Xcode project settings.
- For Android, modify
-
Handling Incoming Links:
- Use the
Linking
API in React Native to handle incoming URLs. - Listen for incoming URLs and parse them to extract the
code
.
- Use the
Best Practices
- Ensure the URL scheme is unique to avoid conflicts with other apps.
- Handle exceptions and edge cases where the URL might not contain the expected parameters.