revoke method
Revoke the OAuth2 token
Implementation
Future<void> revoke() async {
final token = await fresh.token;
if (token == null) return;
final endpoints = await _discover();
final revocation = endpoints.revocation;
if (revocation == null) {
throw Exception('Revocation endpoint not available');
}
final credentials = this.credentials;
final response = await oauthDio.postUri(
revocation,
options: Options(headers: _tokenHeaders),
data: {
if (credentials != null) 'client_id': credentials.id,
'token': token.accessToken,
},
);
if (response.statusCode != 200) {
throw Exception('Failed to revoke token');
}
await fresh.clearToken();
}