StefH / Blazor.WebAssembly.Authentication.Auth0

Blazor WebAssembly Auth0 Oidc Authentication with support for Audience
MIT License
12 stars 7 forks source link

How to use POST? #6

Open vadik12345 opened 3 years ago

vadik12345 commented 3 years ago

Hello,

If I use default value of ProviderOptions.ResponseType then following code works:

    private static void ConfigureServices(this IServiceCollection services, IConfiguration config)
    {
        services.AddAuth0Authentication(options =>
        {
            options.ProviderOptions.Audience = config["Authentication:Audience"];
            options.ProviderOptions.Authority = config["Authentication:Authority"];
            options.ProviderOptions.ClientId = config["Authentication:ClientId"];
            options.ProviderOptions.ResponseType = "token id_token";
            options.ProviderOptions.RedirectUri = "authentication/login-callback";
            options.ProviderOptions.PostLogoutRedirectUri = "authentication/logout-callback";
            options.ProviderOptions.DefaultScopes.Add("email");
            options.AuthenticationPaths.LogOutSucceededPath = "/";

            foreach (var permission in Permission.List)
            {
                options.ProviderOptions.DefaultScopes.Add(permission.Value);
            }
        }).AddAccountClaimsPrincipalFactory<AfoConnectPrincipalFactory>();

      ....
    }

But if I tried to use options.ProviderOptions.ResponseType = "post_form"; then there is problem. private static void ConfigureServices(this IServiceCollection services, IConfiguration config) { services.AddAuth0Authentication(options => { options.ProviderOptions.Audience = config["Authentication:Audience"]; options.ProviderOptions.Authority = config["Authentication:Authority"]; options.ProviderOptions.ClientId = config["Authentication:ClientId"]; options.ProviderOptions.ResponseType = "token id_token"; options.ProviderOptions.RedirectUri = "authentication/login-callback"; options.ProviderOptions.PostLogoutRedirectUri = "authentication/logout-callback"; options.ProviderOptions.DefaultScopes.Add("email"); options.AuthenticationPaths.LogOutSucceededPath = "/"; options.ProviderOptions.ResponseType = "post_form";

            foreach (var permission in Permission.List)
            {
                options.ProviderOptions.DefaultScopes.Add(permission.Value);
            }
        }).AddAccountClaimsPrincipalFactory<AfoConnectPrincipalFactory>();

... }

How to use POST method?

Thank you.