oauth2_dio

Implement

1, OAuthInfoMixin

Object hold info (token, refreshToken) is a mixin of OAuthInfoMixin

2, Create Oauth2Interceptor

    _oauth2manager = Oauth2Manager<SignInResponse>(
        currentValue: token,
        onSave: (value) {
          //TODO Save token to SharePreference
        });
        
    _dio.interceptors.add(
      Oauth2Interceptor(
        dio: _dio,
        oauth2Dio:
            Dio(BaseOptions(baseUrl: 'http://abc.xyz/api/')),
        pathRefreshToken: 'auth/refreshToken',
        parserJson: (json) {
          //TODO Parser json to object which a mixin of OAuthInfoMixin
        },
        tokenProvider: _oauth2manager,
      ),
    );

Libraries

oauth2_dio
oauth2_interceptor
oauth2_manager
refresh_exception