withGenerator static method
Implementation
static Future<Yt> withGenerator(TokenGenerator generator,
{LogOptions logOptions = const LogOptions(
LogLevel.error,
stackTraceLevel: LogLevel.off,
)}) async {
final yt = Yt(logOptions: logOptions);
Token token = await generator.generate();
addInterceptor(InterceptorsWrapper(onRequest: (options, handler) async {
options.headers['Authorization'] = 'Bearer ${token.accessToken}';
return handler.next(options);
}));
yt.setModules(useToken: true);
dio.interceptors.addAll(_interceptors);
return yt;
}