flutter_app_auth_wrapper 0.2.0 copy "flutter_app_auth_wrapper: ^0.2.0" to clipboard
flutter_app_auth_wrapper: ^0.2.0 copied to clipboard

App-Auth wrapper for flutter. Allow user to making OAuth flow by CustomTabs/SafariViewController.

pub package

flutter_app_auth_wrapper #

The package wraps App Auth, an OAuth 2.0 client for native iOS and Android app development, into Flutter. You can use the package to implements Oauth2 Authentication Code Flow in your Flutter app.

Usage #

Start oauth flow

FlutterAppAuthWrapper.startAuth(
                      AuthConfig(
                        clientId: clientId,
                        clientSecret: clientSecret,
                        redirectUrl: redirectURL,
                        state: "login",
                        prompt: "consent",
                        endpoint: 
                        AuthEndpoint(auth: authEndpoint, token: tokenEndpoint),
                        scopes: [
                          "user_account_status",
                          "user_territory",
                          "user_profile"
                        ],
                      ),
                    );
copied to clipboard

Listen result event by FlutterAppAuthWrapper.eventStream().

StreamBuilder(
                initialData: "init state",
                stream: FlutterAppAuthWrapper.eventStream(),
                builder: (context, snapshot) {
                  if (snapshot.hasError) {
                    var error = snapshot.error as PlatformException;
                    return Text("[Error] ${error.message}: ${error.details}");
                  } else {
                    return Text(snapshot.data.toString());
                  }
                },
              )
copied to clipboard

Setting Up #

Android #

Support AndroidX. Add following properties into gradle.properties to enable AndroidX support.

android.enableJetifier=true
android.useAndroidX=true
copied to clipboard

When a custom scheme is used, AppAuth can be easily configured to capture all redirects using this custom scheme through a manifest placeholder:

android.defaultConfig.manifestPlaceholders = [
  'appAuthRedirectScheme': 'com.example.app'
]
copied to clipboard

Alternatively, the redirect URI can be directly configured by adding an intent-filter for AppAuth's RedirectUriReceiverActivity to your AndroidManifest.xml:

<activity
        android:name="net.openid.appauth.RedirectUriReceiverActivity"
        tools:node="replace">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="com.example.app"/>
    </intent-filter>
</activity>
copied to clipboard

For further information, please visit the page of AppAuth Android.

iOS #

You need to add your own custom URL scheme to the Info.plist file.

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleIdentifier</key>
        <string></string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>your_custom_url_scheme</string>
        </array>
    </dict>
</array>
copied to clipboard

For further information, please visit the page of AppAuth iOS.

Use this package as a library #

1. Depend on it #

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_app_auth_wrapper: {last_version}
copied to clipboard

2. Install it #

You can install packages from the command line:

with pub:

$ pub get
copied to clipboard

with Flutter:

$ flutter packages get
copied to clipboard

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it #

Now in your Dart code, you can use:

import 'package:flutter_app_auth_wrapper/flutter_app_auth_wrapper.dart';
copied to clipboard
0
likes
40
points
52
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.19 - 2025.04.03

App-Auth wrapper for flutter. Allow user to making OAuth flow by CustomTabs/SafariViewController.

Repository (GitHub)

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_app_auth_wrapper