Well, it was too complicated ApiKey interceptor
This commit is contained in:
parent
68cdcf45e7
commit
aa04b550c6
1 changed files with 6 additions and 15 deletions
|
|
@ -2,7 +2,6 @@
|
||||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:tuuli_api/src/auth/auth.dart';
|
import 'package:tuuli_api/src/auth/auth.dart';
|
||||||
|
|
||||||
|
|
@ -11,20 +10,12 @@ class ApiKeyAuthInterceptor extends AuthInterceptor {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||||
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'apiKey');
|
for (final entry in apiKeys.entries) {
|
||||||
for (final info in authInfo) {
|
final authName = entry.key;
|
||||||
final authName = info['name'] as String;
|
final apiKey = entry.value;
|
||||||
final authKeyName = info['keyName'] as String;
|
options.headers[authName] = apiKey;
|
||||||
final authWhere = info['where'] as String;
|
|
||||||
final apiKey = apiKeys[authName];
|
|
||||||
if (apiKey != null) {
|
|
||||||
if (authWhere == 'query') {
|
|
||||||
options.queryParameters[authKeyName] = apiKey;
|
|
||||||
} else {
|
|
||||||
options.headers[authKeyName] = apiKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.onRequest(options, handler);
|
super.onRequest(options, handler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue