发现端点可通过/.well-known/openid-configuration相对于基址使用
如: https://demo.identityserver.io/.well-known/openid-configuration
static IDiscoveryCache _cache = new DiscoveryCache("服务器基地址"); var disco = await _cache.GetAsync(); if (disco.IsError) throw new Exception(disco.Error); var client = new HttpClient();
//这里举例密码获取token var response = await client.RequestPasswordTokenAsync(new PasswordTokenRequest { Address = disco.TokenEndpoint, ClientId = "roclient.reference", ClientSecret = "secret", UserName = "bob", Password = "bob", Scope = "scope4.scope" }); if (response.IsError) throw new Exception(response.Error); return response;
需要引用: IdentityModel
原文:https://www.cnblogs.com/myfqm/p/13156666.html