native_authentication 0.1.4 copy "native_authentication: ^0.1.4" to clipboard
native_authentication: ^0.1.4 copied to clipboard

Native bindings for platform-specific authentication APIs like ASWebAuthenticationSession and Chrome Custom Tabs.

native_authentication #

A Dart-only library for performing authentication flows using native APIs.

The platform implementations for NativeAuthentication are:

Platform Implementation
iOS/macOS ASWebAuthenticationSession
Android Auth Tabs
Linux/Windows Localhost HTTP server
Web HTTP Redirects

Android #

NOTE: For HTTPS callbacks to work correctly, you must enable domain verification.

The Android implementation uses Auth Tabs for authentication, which is an improvement to Custom Tabs. When Auth Tabs are available, no extra configuration is needed to use either a custom scheme or an HTTPS URL as a callback. However, when the Auth Tabs feature is not available the implementation will fall back to Custom Tabs, so it is recommended to update your AndroidManifest.xml with one of the following configurations to ensure that the authentication flow works correctly.

Start by modifying your AndroidManifest.xml to enable the OnBackInvokedCallback feature, which is required for handling the back button correctly in the authentication flow. Add the following line to your <application> tag:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application
        android:label="My App"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher"
+        android:enableOnBackInvokedCallback="true">

Then, to configure a custom scheme, add the following to your AndroidManifest.xml application tag:

<activity
        android:name="dev.celest.native_authentication.CallbackReceiverActivity"
        android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <!-- Update this -->
        <data android:scheme="my-app" />
    </intent-filter>
</activity>

To configure an HTTPS URL, for example to support App Links, add the following to your AndroidManifest.xml application tag:

<activity
        android:name="dev.celest.native_authentication.CallbackReceiverActivity"
        android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <!-- Update this -->
        <data android:scheme="https"
              android:host="app.example.com"
              android:path="/auth/callback"/>
    </intent-filter>
</activity>
2
likes
150
points
356
downloads

Publisher

verified publishercelest.dev

Weekly Downloads

Native bindings for platform-specific authentication APIs like ASWebAuthenticationSession and Chrome Custom Tabs.

Repository (GitHub)

Documentation

API reference

License

BSD-2-Clause-Patent (license)

Dependencies

ffi, jni, logging, meta, objective_c, path, stream_transform, web

More

Packages that depend on native_authentication