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

outdated

An token refresh library for dart. This package exposes the core components that are common to various refresh token implementations (REST, GraphQL, etc...).

example/main.dart

import 'package:fresh/fresh.dart';

class InMemoryTokenStorage implements TokenStorage<OAuth2Token> {
  OAuth2Token _token;

  @override
  Future<void> delete() async {
    _token = null;
  }

  @override
  Future<OAuth2Token> read() async {
    return _token;
  }

  @override
  Future<void> write(OAuth2Token token) async {
    _token = token;
  }
}

void main() {
  // Configure appropriate fresh client using `TokenStorage` implementation.
  // For example using [fresh_dio](https://pub.dev/packages/fresh_dio)...
  /// ```dart
  /// final dio = Dio()
  ///   ..interceptors.add(
  ///     Fresh<OAuth2Token>(
  ///       tokenStorage: InMemoryTokenStorage(),
  ///       refreshToken: (token, client) {
  ///         // Perform refresh and return new token
  ///       },
  ///     ),
  ///   );
  // ```
}
141
likes
0
pub points
80%
popularity

Publisher

verified publisherfelangel.dev

An token refresh library for dart. This package exposes the core components that are common to various refresh token implementations (REST, GraphQL, etc...).

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

meta

More

Packages that depend on fresh