diff --git a/src/cli/Botpress.CLI/CliRuntime.cs b/src/cli/Botpress.CLI/CliRuntime.cs index 584263c..003d292 100644 --- a/src/cli/Botpress.CLI/CliRuntime.cs +++ b/src/cli/Botpress.CLI/CliRuntime.cs @@ -24,14 +24,12 @@ internal static class CliRuntime ? new global::System.Collections.Generic.List() : new global::System.Collections.Generic.List { - new global::Botpress.EndPointAuthorization - { - Type = "Http", - SchemeId = "HttpBearer", - Location = "Header", - Name = "Bearer", - Value = apiKey, - }, + CreateAuthorization( + type: "Http", + schemeId: "HttpBearer", + location: "Header", + name: "Bearer", + value: apiKey), }; var baseUri = ResolveBaseUri(parseResult); @@ -42,6 +40,30 @@ internal static class CliRuntime disposeHttpClient: true); } + private static global::Botpress.EndPointAuthorization CreateAuthorization( + string type, + string schemeId, + string location, + string name, + string value) + { + var authorization = new global::Botpress.EndPointAuthorization + { + Type = type, + Location = location, + Name = name, + Value = value, + }; + + var schemeIdProperty = typeof(global::Botpress.EndPointAuthorization).GetProperty("SchemeId"); + if (schemeIdProperty?.CanWrite == true) + { + schemeIdProperty.SetValue(authorization, schemeId); + } + + return authorization; + } + [System.Diagnostics.CodeAnalysis.SuppressMessage( "Design", "CA1031:Do not catch general exception types",