Skip to content

Wanted to extend UserAgentBuilder class to pass custom user-agent value #60

@PranithaReddyAedla

Description

@PranithaReddyAedla

I wanted to pass custom user-agent value for all factor authn requests

For that, I wanted to extend UserAgentBuilder class of Okta.Sdk.Abstractions and modify Generate() method to achieve what I wanted exactly. Since, UserAgentBuilder class is being a sealed type class that is not being possible now.

Currently, UserAgentBuilder generates user-agent value as "custom/{sdk-version} runtime/{runtime-info} os/{os-info}"

But, the following is how I need generate to user-agent value.
User-Agent = "machineName/{machine-name-here} machineIp/{ip-address-here} os/{os-info-here} runtime/{runtime-info-here}

private string Generate()
        {
            var machineName = $"machineName/{Environment.MachineName}";

            var machineIP = $"machineIP/{this.GetLocalIPAddress()}";

            var runtimeToken = $"runtime/{UserAgentHelper.GetRuntimeVersion()}";

            var operatingSystemToken = $"os/{Sanitize(RuntimeInformation.OSDescription)}";

            return string.Join(
                " ",
                machineName,
                machineIP,
                operatingSystemToken,
                runtimeToken)
            .Trim();
        }

Could you please me help with this? Is it possible to modify access-specifier of UserAgentBuilder? Or Is there any possible way that you can propose to solve my issue?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions