public static SaasApiClientCredentialBuilder AddSaasApiCertificateClientCredentials()

in src/Saas.Lib/Saas.Identity/Extensions/SaasIdentityConfigurationBuilderExtensions.api.cs [14:45]


    public static SaasApiClientCredentialBuilder<TProvider, TOptions> AddSaasApiCertificateClientCredentials<TProvider, TOptions>(
        this IServiceCollection services, 
        IEnumerable<string>? scopes = default)
        where TProvider : ISaasApi
        where TOptions : AzureAdB2CBase
    {

        services.AddMemoryCache();
        services.AddSingleton<IPublicX509CertificateDetailProvider, PublicX509CertificateDetailProvider>();
        services.AddSingleton<IClientAssertionSigningProvider, ClientAssertionSigningProvider>();
        services.AddScoped<SaasApiAuthenticationProvider<TProvider, TOptions>>();

        switch (scopes)
        {
            case null when (typeof(TProvider).Equals(typeof(ISaasMicrosoftGraphApi))):
                {
                    services.Configure<SaasApiScopeOptions<TProvider>>(options
                        => options.Scopes = new[] { "https://graph.microsoft.com/.default" });
                    break;
                }
            case null:
                throw new ArgumentException("Client Credentials scopes must be defined in the form: <Some App Id uri>/.default");
            default:
                {
                    services.Configure<SaasApiScopeOptions<TProvider>>(options
                        => options.Scopes = scopes.ToArray());
                    break;
                }
        }

        return new SaasApiClientCredentialBuilder<TProvider, TOptions>(services);
    }