Skip to content

Commit

Permalink
Specifies a generic type on the Fresh field
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexios80 committed Sep 9, 2024
1 parent f0898a8 commit c647058
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.6

- Specifies a generic type on the `Fresh` field

## 0.0.5

- Fixes token refresh serialization issue
Expand Down
11 changes: 7 additions & 4 deletions lib/src/oauth_flutter_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class OAuth2Client<T extends SecureOAuth2Token> {
final OAuth2Verification verification;

/// The token refresher
late final Fresh fresh;
late final Fresh<T> fresh;

/// Create an OAuth2 client
///
Expand All @@ -109,13 +109,16 @@ class OAuth2Client<T extends SecureOAuth2Token> {
if (endpoints != null) {
_endpoints.complete(endpoints);
}
fresh = Fresh.oAuth2(
fresh = Fresh(
tokenHeader: (token) => {
'authorization': '${token.tokenType} ${token.accessToken}',
},
tokenStorage: SecureTokenStorage(
key: '$_keyPrefix$key',
decoder: this.tokenDecoder,
),
refreshToken: (token, dio) => _refreshToken(
oldToken: token as T?,
oldToken: token,
onReAuthenticate: onReAuthenticate ?? authenticate,
),
);
Expand Down Expand Up @@ -275,7 +278,7 @@ class OAuth2Client<T extends SecureOAuth2Token> {

/// Revoke the OAuth2 token
Future<void> revoke() async {
final token = await fresh.token as T?;
final token = await fresh.token;
if (token == null) return;

final endpoints = await _discover();
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: oauth_flutter
description: "A complete OAuth2 solution for Flutter apps. Handles auth, token storage, and token refresh."
version: 0.0.5
version: 0.0.6
homepage: https://github.com/IO-Design-Team/oauth_flutter

environment:
Expand Down

0 comments on commit c647058

Please sign in to comment.