Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions src/cli/Botpress.CLI/CliRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ internal static class CliRuntime
? new global::System.Collections.Generic.List<global::Botpress.EndPointAuthorization>()
: new global::System.Collections.Generic.List<global::Botpress.EndPointAuthorization>
{
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);

Expand All @@ -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",
Expand Down