openapi-generator-dart icon indicating copy to clipboard operation
openapi-generator-dart copied to clipboard

How to set bearer token to client

Open ChanakaWeerasinghe opened this issue 3 years ago • 1 comments

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);
    }
  }

ChanakaWeerasinghe avatar Jan 07 '22 15:01 ChanakaWeerasinghe

Your spec needs to have the security scheme defined first.

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

gibahjoe avatar Feb 05 '22 22:02 gibahjoe