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

Flutter library for @QBitArtifact's Superadmin

sa_flutter #

Pub Version

Flutter library for @QBitArtifact's Superadmin. It handles Auth and some other stuff for you.

NOTICE: Library under development, use at own risk

Getting Started #

Add dependency to pubspec.yaml: #

dependencies:
  sa_flutter: <latest_version>

Usage #

Sign in to SuperAdmin, and get a token: #

  1. Instantiate SaAuthService with proper config
final auth = SaAuthService(
    'https://api.caste.qbitartifacts.com',
    realm: '<your_realm>',
);
  1. Now we can use the service:
var tokenData = await auth.signIn('username', 'password');
var payload = SaAuthService.decodeToken(tokenData['token']);
  1. Now we can use this token to authenticate against SuperAdmin itself or other APIs that integrate SA.

Header will have this format:

'Authorization': 'Bearer <token>'

Using Management Services #

To be able to use management service, we recomend creating a factory that returns the configured service.

Creating instances

import 'package:sa_flutter/sa_flutter.dart';

class TokenGetter implements WithTokenGetter {
  @override
  Future<String> getToken() {
    return <token>;
  }
}
final tokenGetter = new TokenGetter();

class ServiceFactory {
  factory accountsService() {
    return new SaAccountsService(tokenGetter, 'https://api.caste.qbitartifacts.com');
  }

  factory applicationsService() {
    return new SaApplicationsService(tokenGetter, 'https://api.caste.qbitartifacts.com');
  }
}

You should only create factories for services you will need.

0
likes
90
pub points
0%
popularity

Publisher

unverified uploader

Flutter library for @QBitArtifact's Superadmin

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, http, jwt_decode

More

Packages that depend on sa_flutter