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!
|
||||
//
|
||||
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:tuuli_api/src/auth/auth.dart';
|
||||
|
||||
|
|
@ -11,20 +10,12 @@ class ApiKeyAuthInterceptor extends AuthInterceptor {
|
|||
|
||||
@override
|
||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'apiKey');
|
||||
for (final info in authInfo) {
|
||||
final authName = info['name'] as String;
|
||||
final authKeyName = info['keyName'] as String;
|
||||
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;
|
||||
}
|
||||
}
|
||||
for (final entry in apiKeys.entries) {
|
||||
final authName = entry.key;
|
||||
final apiKey = entry.value;
|
||||
options.headers[authName] = apiKey;
|
||||
|
||||
super.onRequest(options, handler);
|
||||
}
|
||||
super.onRequest(options, handler);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue