| 1 | // |
| 2 | // AUTO-GENERATED FILE, DO NOT MODIFY! |
| 3 | // |
| 4 | |
| 5 | import 'dart:convert'; |
| 6 | |
| 7 | import 'package:dio/dio.dart'; |
| 8 | import 'package:openapi/src/auth/auth.dart'; |
| 9 | |
| 10 | class BasicAuthInfo { |
| 11 | final String username; |
| 12 | final String password; |
| 13 | |
| 14 | const BasicAuthInfo(this |
| 15 | } |
| 16 | |
| 17 | class BasicAuthInterceptor extends AuthInterceptor |
| 18 | final Map<String |
| 19 | |
| 20 | @override |
| 21 | void onRequest( |
| 22 | RequestOptions options, |
| 23 | RequestInterceptorHandler handler, |
| 24 | ) { |
| 25 | final metadataAuthInfo = getAuthInfo(options |
| 26 | for (final info in metadataAuthInfo) { |
| 27 | final authName = info['name'] as |
| 28 | final basicAuthInfo = authInfo[authName]; |
| 29 | if (basicAuthInfo != null) { |
| 30 | final basicAuth = 'Basic ${base64Encode |
| 31 | options.headers['Authorization'] = basicAuth; |
| 32 | break; |
| 33 | } |
| 34 | } |
| 35 | super.onRequest(options, handler) |
| 36 | } |
| 37 | } |