title: How to retrieve Parameters set on AuthenticationProperties in IdentityServer4 OIDC challenge?
body: <p>I have IdentityServer4 running as the auth system wired up to use both Google and Amazon along with the local accounts. I have a separate web app using the IdentityServer4 system as the oidc auth provider and things seem to work with authenticating and issuing tokens.  The issue is that it does not maintain the returnUrl after authentication.  I am using the OIDC StateDataFormatterCache that is built-in to Id4 via the Redis distributed cache and have verified in Redis that it is writing the redirect and even a test parameter I added at challenge time.</p>
  
  <p>After authentication it does not redirect me back to the original url and when I try to access the parameters and AuthenticationProperties set in the challenge, they don't seem to be there after authentication.</p>
  
  <p>I have stepped through the code on the IdentityServer4 side where the login for local and external callback are and the returnUrl never shows up over there. I assume that the OIDC StateDataFormatterCache intercepts this to prevent the potential long url issues and is supposed to intercept the response and inject the return url. That part doesn't seem to work so I was trying to see if I could stick in my own custom parameter into the auth props and grab it back out after auth occurs but that turns up empty. AuthenticationProperties just seems to have the access_token, refresh_token, id_token,etc but is missing the redirect url and my custom parameter.</p>
  
  <pre class="lang-cs prettyprint-override"><code>services.AddOidcStateDataFormatterCache("oidc");
  ...
  var authProps = new AuthenticationProperties { RedirectUri = originalPath + context.Request.QueryString };
  
  Microsoft.Extensions.Primitives.StringValues stateValue;
  
  if (context.Request.Query.TryGetValue("state", out stateValue))
  {
     authProps.SetParameter("itk", stateValue);
  }
  
  await Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.ChallengeAsync(context,"oidc", authProps); //authProps has custom parameter 'itk' and a redirect
  ...
  var authContext = await context.AuthenticateAsync("oidc");
  //authContext.Properties has data but not the RedirectUri or the custom parameter I set and verified to exist in the redis store
  </code></pre>
  
  <p>Here's what shows up in Redis:</p>
  
  <pre><code>{
    "Items": {
      ".redirect": "/?state=foo",
      ".xsrf": "DkRjG29eE4qDFaNLSktyTDKfhdzXH8FfVpAwBbje6tc",
      "OpenIdConnect.Code.RedirectUri": "https://localhost/signin-oidc"
    },
    "Parameters": {
      "itk": [
        "foo"
      ]
    },
    "RedirectUri": "/?state=foo"
  }
  </code></pre>
  
  <p>Any ideas on why I am unable to retrieve the info placed into Redis by the state data formatter?</p>
  
  <p>I need to be able to get the value of "itk" in the Parameters.</p>
  
  <p>I found my issue with the redirect not getting through but I still need to be able to get that Parameter.</p>