rook_auth 0.0.1 copy "rook_auth: ^0.0.1" to clipboard
rook_auth: ^0.0.1 copied to clipboard

discontinued
outdated

Grant usage permissions to other rook packages.

Rook authorization #

This is the main package required by all rook packages to enable their usage.

Features #

  • Obtain and save authorization to use other rook packages with your client UUID.

Getting started #

Logging #

If you want to see the logs generated by this package

Install the logger package:

logging: ">=1.0.0 <2.0.0"

Add the following snippet in your main() function:

void main() {
  Logger.root.level = Level.ALL;
  Logger.root.onRecord.listen((record) {
    if (kDebugMode) {
      print('${record.level.name}: ${record.time}: ${record.message}');
    }
  });

  runApp(RookApp());
}

Usage #

You must check authorization every time your app starts or before using other rook packages.

  1. Create an AuthorizationProvider instance providing the core URL without https.
import 'package:rook_auth/rook_auth.dart';

final provider = AuthorizationProvider('api2.rookmotion.review');
  1. call getAuthorization providing your client UUID, this will ask the server for a token which contains the packages you are allowed to use, and save this information in the device's local preferences.
void initialize() async {
  final result = await provider.getAuthorization(clientUUID);
}

This method returns a Future of AuthorizationResult described below:

class AuthorizationResult {
  final AuthorizationOrigin origin; // Where the authorization was retrieved from.
  final Authorization authorization; // Authorization returned by server/preferences.
}

enum AuthorizationOrigin {
  remote, // The authorization was retrieved from server.
  local // The authorization was retrieved from preferences, this happens when the device does not have an active internet connection or if the request to the server fails.
}

class Authorization {
  DateTime authorizedUntil; // Expire date (UTC).
  Map<Feature, bool> features; // Features (packages) that are enabled or disabled.
}

Additional information #

The first time your users use this package they MUST have an active internet connection otherwise the request will fail and a default authorization will be returned.

  • The default authorization has all packages disabled.

Authorization is stored in device's shared preferences, if your app is also using shared preferences keep in mind that calling clear on the SharedPreferences instance will also delete this package registries.

1
likes
0
points
66
downloads

Publisher

verified publisherrook-connect.com

Weekly Downloads

Grant usage permissions to other rook packages.

Homepage

License

unknown (license)

Dependencies

flutter, http, jwt_decode, logging, shared_preferences

More

Packages that depend on rook_auth