Hosted Authentication
Register or log in a user using a Passage Hosted Login page
Passage Hosted Authentication handles user authentication by opening a browser tab for login or sign-up. This simplifies the process, allowing Passage to manage the authentication seamlessly when users need access to your application.
Note: This feature is only available for Android and iOS at the moment.
Prerequisites
Android and iOS platforms each have their own configuration steps required to provide Hosted Login to your users.
iOS
iOS Prerequisite: Setup Universal Linking (opens in a new tab)
To register or log in your user, use passage.hostedAuthIOS()
:
await passage.hostedAuthIOS();
Android
Android Prerequisite: Setup App Links (opens in a new tab)
Starting hosted authorization
To begin registering or logging in a user using a Hosted Authorization, simply call passage.hosted.start()
. Here is an example using Hosted Authorization:
await passage.hosted.start()
This will open up a secure web view where the user will be prompted to authorize your app.
Finish authentication
When the user has successfully authorized in the web view, they will be redirected into your app where you will receive an authorization code and state. You will use these code and state to finish authentication.
var uri = Uri.parse(link!);
var code = uri.queryParameters['code'];
var state = uri.queryParameters['state'];
await _passage.hosted.finish(code!, state!);
Logout
The secure hosted web view will keep your auth session until it expires. To clear the web view auth session and remove user's tokens from device, use passage.currentUser.logout()
await passage.currentUser.logout()