LukasPoque / s3i_flutter

A library that makes it easy to communicate with the S³I (Smart Systems Service Infrastructure of the KWH4.0)
https://pub.dev/packages/s3i_flutter
MIT License
4 stars 1 forks source link

MaxRetryException is thrown although token could be received from OAuthProxy #7

Closed LukasPoque closed 2 years ago

LukasPoque commented 2 years ago

If the onAuthSuccess callback in the OAuthProxyFlow throws an exception, the getAccessToken method couldn't return the token and tries it until maxRetryPickup is reached.

See https://github.com/LukasPoque/s3i_flutter/blob/7e3e0bb29345a2bed7868f753efd3efd0acca868/lib/src/auth/oauth_proxy_flow.dart#L149 :

try {
  _parseAndSetTokenResponse(response.body);
  if (onAuthSuccess != null) onAuthSuccess!(_accessToken!);
  return _accessToken!;
} catch (e) {
  //catches everything
}

The problem is that an exception in onAuthSuccess is caught.

LukasPoque commented 2 years ago

Maybe this is no real problem/bug. The developers should ensure that their onAuthSuccess callbacks couldn't throw anything if they don't want this behavior.

In my opinion, this should be better documented!

LukasPoque commented 2 years ago

This problem should be fixed with #11