asp.net web form client with identity server 4 : <p>I have a asp.net solution which consists of</p>

<pre><code>1). asp.net identity server rc 3
2). asp.net Core web api
3). asp.net webform ( not in asp.net core, client)
</code></pre>

<p>I don't see any sample with identity server 4 and web form client. Can you please suggest how to authenticate web form user using identity server with asp.net identity and then call api with the access token ?</p>

<p>I don't see identity server 4 sample with <a href="https://github.com/IdentityServer/IdentityServer4.Samples/tree/dev/Clients/src" rel="noreferrer">web form client</a> or <a href="https://github.com/IdentityServer/IdentityServer4.Samples/tree/dev/Quickstarts" rel="noreferrer">sample</a> </p>

<p>identity server 3 has a <a href="https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/Clients/WebFormsClient" rel="noreferrer">sample</a>  but it is doing everything in <a href="https://github.com/IdentityServer/IdentityServer3.Samples/blob/master/source/Clients/WebFormsClient/Startup.cs" rel="noreferrer">startup</a> </p>

<p>When i see <a href="https://github.com/IdentityServer/IdentityServer4.Samples/blob/dev/Quickstarts/6_AspNetIdentity/src/MvcClient/Startup.cs" rel="noreferrer">mvc client</a> for identity server 4, it has all settings in configure method and then calls it like <a href="https://github.com/IdentityServer/IdentityServer4.Samples/blob/dev/Quickstarts/6_AspNetIdentity/src/MvcClient/Controllers/HomeController.cs" rel="noreferrer">this</a></p>

<p>How will i apply Authorize attribute in webform so that i am redirected to identity server 4 for login and then after login when i call api like this:</p>

<p>how to change client for webform ?</p>

<pre><code> new Client()
                  {
                    ClientId = "mvcClient",
                    ClientName = "MVC Client",                    
                    AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,

                    ClientSecrets = new List&lt;Secret&gt;()
                    {
                        new Secret("secret".Sha256())
                    },

                    RequireConsent = false;

                    // where to redirect to after login
                    RedirectUris = { "http://localhost:5002/signin-oidc" },
                    // where to redirect to after logout
                    PostLogoutRedirectUris = { "http://localhost:5002" },

                    AllowedScopes =
                    {
                        StandardScopes.OpenId.Name,
                        StandardScopes.Profile.Name,
                        StandardScopes.OfflineAccess.Name,
                        StandardScopes.Roles.Name,
                        "API"
                    }
                }

new InMemoryUser()
            {
                Subject = "1",
                Username = "testuser",
                Password = "password",
                Claims = new List&lt;Claim&gt;()
                {
                    new Claim("name", "Alice"),
                    new Claim("Website", "http://alice.com"),
                     new Claim(JwtClaimTypes.Role, "admin")

                }
            }


 return new List&lt;Scope&gt;()
                {
                    StandardScopes.OpenId, // subject id
                    StandardScopes.Profile, // first name, last name
                    StandardScopes.OfflineAccess, 
                   StandardScopes.Roles,
                    new Scope()
                    {
                        Name = "API",
                        Description = "API desc",
                         Type = ScopeType.Resource,
                        Emphasize = true,
                        IncludeAllClaimsForUser = true,
                        Claims = new List&lt;ScopeClaim&gt;
                        {
                            new ScopeClaim(ClaimTypes.Name),      
                            new ScopeClaim(ClaimTypes.Role)
                        }
                    }
                };


 public void CallApiUsingClientCredentials()
                {
                    var tokenClient = new TokenClient("http://localhost:5000/connect/token", "mvc", "secret");
                    var tokenResponse = await tokenClient.RequestClientCredentialsAsync("api1");

                    var client = new HttpClient();
                    client.SetBearerToken(tokenResponse.AccessToken);
                    var content = await client.GetStringAsync("http://localhost:5001/identity");

                    var result = JArray.Parse(content).ToString();

                }

 [Authorize(Roles="admin)]
          [HttpGet]
           public IActionResult Get()
                    {
                        return new JsonResult(from c in User.Claims select new { c.Type, c.Value });
                }
</code></pre>
