gibahjoe / openapi-generator-dart

Openapi Generator for Dart/Flutter
BSD 3-Clause "New" or "Revised" License
123 stars 34 forks source link

How to set bearer token to client #64

Open ChanakaWeerasinghe opened 2 years ago

ChanakaWeerasinghe commented 2 years ago

Im trying to setup token to api_client please help i cant find

_authentications['isOAuth'] = new OAuth("sdfd");

it will throw this throw ArgumentError('Authentication undefined: $authName');

 /// Update query and header parameters based on authentication settings.
  /// @param authNames The authentications to apply
  void _updateParamsForAuth(
    List<String> authNames,
    List<QueryParam> queryParams,
    Map<String, String> headerParams,
  ) {
    for (final authName in authNames) {
      final auth = _authentications[authName];
      if (auth == null) {
        throw ArgumentError('Authentication undefined: $authName');
      }
      auth.applyToParams(queryParams, headerParams);
    }
  }
gibahjoe commented 2 years ago

Your spec needs to have the security scheme defined first.

Then configure it using new Api().setOAuthToken();