title: Authorization with apikey in headers using dio and generated client libraries by openapi-generator-dart
body: <p>I created client libraries in a flutter project using the DioNext generator from openapi-generator-dart.
  The api I am trying to communicate with uses an apikey as the authentication method and it uses it in the url, i.e when I am accessing the api through my Google Chrome browser:
  <code>https://api.hotelsexample.com/hotelfinder/v1/countries/en_US/hotels/A000293?apikey=9dhsu8d8-an9c-d40e1-a11c-5s84ddewda5</code></p>
  <p>Now the method generated to get, i.e. a hotel, by DioNext looks like the following, and there are many endpoints like this, so I do not want to change the generated code:</p>
  <pre><code>  Future&lt;Response&lt;Hotel&gt;&gt; hotelGET({ 
      required String countryId,
      required String hotelId,
      BuiltList&lt;String&gt;? fieldsFilter,
      CancelToken? cancelToken,
      Map&lt;String, dynamic&gt;? headers,
      Map&lt;String, dynamic&gt;? extra,
      ValidateStatus? validateStatus,
      ProgressCallback? onSendProgress,
      ProgressCallback? onReceiveProgress,
    }) async {
      final _path = r'/countries/{countryId}/hotels/{hotelId}'.replaceAll('{' r'countryId' '}', countryId.toString()).replaceAll('{' r'hotelId' '}', hotelId.toString());
      final _options = Options(
        method: r'GET',
        headers: &lt;String, dynamic&gt;{
          ...?headers,
        },
        extra: &lt;String, dynamic&gt;{
          'secure': &lt;Map&lt;String, String&gt;&gt;[
            {
              'type': 'apiKey',
              'name': 'apikey',
              'keyName': 'apikey',
              'where': 'query',
            },
          ],
          ...?extra,
        },
        validateStatus: validateStatus,
      );
  
      final _queryParameters = &lt;String, dynamic&gt;{
        if (fieldsFilter != null) r'fieldsFilter': encodeCollectionQueryParameter&lt;String&gt;(_serializers, fieldsFilter, const FullType(BuiltList, [FullType(String)]), format: ListFormat.multi,),
      };
  
      final _response = await _dio.request&lt;Object&gt;(
        _path,
        options: _options,
        queryParameters: _queryParameters,
        cancelToken: cancelToken,
        onSendProgress: onSendProgress,
        onReceiveProgress: onReceiveProgress,
      );
  
      Hotel _responseData;
  
      try {
        const _responseType = FullType(Hotel);
        _responseData = _serializers.deserialize(
          _response.data!,
          specifiedType: _responseType,
        ) as Hotel;
  
      } catch (error, stackTrace) {
        throw DioError(
          requestOptions: _response.requestOptions,
          response: _response,
          type: DioErrorType.other,
          error: error,
        )..stackTrace = stackTrace;
      }
  
      return Response&lt;Hotel&gt;(
        data: _responseData,
        headers: _response.headers,
        isRedirect: _response.isRedirect,
        requestOptions: _response.requestOptions,
        redirects: _response.redirects,
        statusCode: _response.statusCode,
        statusMessage: _response.statusMessage,
        extra: _response.extra,
      );
    }
  </code></pre>
  <p>Now, when I try to call the api using the following method:</p>
  <pre><code>void getmyhotel() async {
      final api = Hotelsexample().getReferencesApi();
      final countryId = &quot;en_US&quot;;
      final hotelId = &quot;A000293&quot;;
  
      try {
        final response = await api.hotelGET(
            countryId: countryId,
            hotelId: hotelId,
            headers: {&quot;apikey&quot;: &quot;9dhsu8d8-an9c-d40e1-a11c-5s84ddewda5&quot;});
        print(answer);
      } catch (e) {
        print(
            &quot;Exception: $e\n&quot;);
      }
    }
  
  </code></pre>
  <p>I get the error of an invalid apikey, so the apikey is not recognized by the api server.
  Where do I have to place the apikey in my code?</p>
  <p>Thank you very much!</p>