Starts in:
1 DAY
2 HRS
43 MIN
24 SEC
Starts in:
1 D
2 H
43 M
24 S
Open Closed

Identity Server Consent Page Error #36


User avatar
0
rajasekhard2015 created

I have created one Client in Identity Server with all required configurations. Client application login has succeded but when clicking on Yes,Allow option in consent page giving error like ArgumentNullException: Value cannot be null. (Parameter 'second'). Can you tell what configuration i missed while creating client.

Sample Data URL:

http://localhost:44351/consent?returnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Dmvc.implicit%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A21402%252Fsignin-oidc%26response_type%3Did_token%26scope%3Dopenid%2520profile%2520email%26response_mode%3Dform_post%26nonce%3D637181387485985316.YmNkNDYyZWQtOTBiYy00MDIxLTgwMzgtYzY3ZGM0OWYzMjI5ODMzZDg2OGMtN2VkMS00YmQ5LThlNzAtMjMwYjU4Y2Q4YTA4%26state%3DCfDJ8OToepw-pxhLsLib8_tnic1n2dCA4B9bn481d71j-eKHvbJHwL4SzGT7r6ue2yiVi__0dnn1GHDX3RXuqRDMih1kpZ_S59zFz95QhqBfEg5KKzPyQWHb5aS5z1K67c9iJNVXZNP6s6G3GRc7_86SaSLGrw5FfDw72BrtKy320VtugUp_diljTmwNfcoZ9-cIaqeaWKOzyWqViYpWFI_E2PcLXLp8RIxck8UubN-VFpyV9zHQDKs9OCecyGQFDG5P9CzdGsHeWltX0Ar4MEOkRZqexF7W1UWwAB2TyvfV69K--bQ-08vUubrejB23gDunhh_audh3xRsK_vctaW9DgWY%26x-client-SKU%3DID_NETSTANDARD2_0%26x-client-ver%3D5.3.0.0


5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi rajasekhard2015 Can you share the full steps to reproduce your problem?

  • User Avatar
    0
    rajasekhard2015 created

    Hi maliming,

    Thanks for reply. Below are the steps i have done for Identity Server Client creation.Please check and help to solve my problem.

    Service Provider Test Application

    Clicking on Yes,Allow button in consent page getting error as ahown in below image

    In Service Provider application,Configured the Idendity Provider Client details like as below.

    services.AddAuthentication(options =>
                {
                    options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    options.DefaultChallengeScheme = "oidc";
                })
                    .AddCookie(options =>
                    {
                        options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
                        options.Cookie.Name = "mvcimplicit";
                    })
                   .AddOpenIdConnect("oidc", options =>
                   {
                       options.Authority = Constants.Authority;
                       options.RequireHttpsMetadata = false;
    
                       options.ClientId = "mvcimplicit";
    
                       options.Scope.Clear();
                       options.Scope.Add("openid");
                       options.Scope.Add("profile");
                       options.Scope.Add("email");                 
    
                       options.SaveTokens = true;
    
                       options.TokenValidationParameters = new TokenValidationParameters
                       {
                           NameClaimType = JwtClaimTypes.Name,
                           RoleClaimType = JwtClaimTypes.Role,
                       };
                   });
    
  • User Avatar
    1
    maliming created
    Support Team Fullstack Developer

    hi

    We will fix this problem, you can use the code below to solve it temporarily.

    [ExposeServices(typeof(ConsentModel))]
    public class MyConsentModel : ConsentModel
    {
    	private readonly IIdentityServerInteractionService _interaction;
    
    	public MyConsentModel(
    		IIdentityServerInteractionService interaction, 
    		IClientStore clientStore,
    		IResourceStore resourceStore) 
    		: base(interaction, clientStore, resourceStore)
    	{
    		_interaction = interaction;
    	}
    
    	protected override async Task<ConsentModel.ProcessConsentResult> ProcessConsentAsync()
    	{
    		var result = new ConsentModel.ProcessConsentResult();
    
    		ConsentResponse grantedConsent;
    
    		if (ConsentInput.UserDecision == "no")
    		{
    			grantedConsent = ConsentResponse.Denied;
    		}
    		else
    		{
    			if (ConsentInput.IdentityScopes.Any() || ConsentInput.ApiScopes.Any())
    			{
    				var identityScopes = ConsentInput.IdentityScopes ?? new List<ConsentModel.ScopeViewModel>();
    				var apiScopes = ConsentInput.ApiScopes ?? new List<ConsentModel.ScopeViewModel>();
    
    				grantedConsent = new ConsentResponse
    				{
    					RememberConsent = ConsentInput.RememberConsent,
    					ScopesConsented = identityScopes.Union(apiScopes).Where(s => s.Checked).Select(s => s.Name).ToList()
    				};
    			}
    			else
    			{
    				throw new UserFriendlyException("You must pick at least one permission"); //TODO: How to handle this
    			}
    		}
    
    		if (grantedConsent != null)
    		{
    			var request = await _interaction.GetAuthorizationContextAsync(ReturnUrl);
    			if (request == null)
    			{
    				return result;
    			}
    
    			await _interaction.GrantConsentAsync(request, grantedConsent);
    
    			result.RedirectUri = ReturnUrl; //TODO: ReturnUrlHash?
    		}
    
    		return result;
    	}
    }
    
    
  • User Avatar
    0
    rajasekhard2015 created

    Thanks for your solution its working for now.

    Please reply us when the issue is fixed.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    It is expected to be resolved in version 2.2. Please stay tuned.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06