public static async Task RenderOAuth2Redirect()

in src/Microsoft.Azure.WebJobs.Extensions.OpenApi/OpenApiTriggerFunctions.cs [254:300]


        public static async Task<IActionResult> RenderOAuth2Redirect(
            [OpenApiHttpTriggerContext] OpenApiHttpTriggerContext openApiContext,
            HttpRequest req, ExecutionContext ctx, ILogger log)
        {
            log.LogInformation("The oauth2-redirect.html page was requested.");

            var request = new HttpRequestObject(req);
            var result = default(string);
            var content = default(ContentResult);
            try
            {
                await openApiContext.SetApplicationAssemblyAsync(ctx.FunctionAppDirectory)
                             .ConfigureAwait(false);

                result = await openApiContext.SwaggerUI
                                      .AddServer(request, openApiContext.HttpSettings.RoutePrefix, openApiContext.OpenApiConfigurationOptions)
                                      .BuildOAuth2RedirectAsync(openApiContext.PackageAssembly)
                                      .RenderOAuth2RedirectAsync("oauth2-redirect.html", openApiContext.GetDocumentAuthLevel(), openApiContext.GetSwaggerAuthKey())
                                      .ConfigureAwait(false);

                content = new ContentResult()
                {
                    Content = result,
                    ContentType = ContentTypeHtml,
                    StatusCode = (int)HttpStatusCode.OK,
                };
            }
            catch (Exception ex)
            {
                log.LogError(ex.Message);

                result = ex.Message;
                if (openApiContext.IsDevelopment)
                {
                    result += "\r\n\r\n";
                    result += ex.StackTrace;
                }
                content = new ContentResult()
                {
                    Content = result,
                    ContentType = ContentTypeText,
                    StatusCode = (int)HttpStatusCode.InternalServerError,
                };
            }

            return content;
        }