我正在 .net core 2.0 中实现身份服务器 4。通过使用 RequestResourceOwnerPasswordAsync 方法,我可以获得 accessToken 但刷新令牌为空。这是代码:
var disco = await DiscoveryClient.GetAsync("http://localhost:5000");
if (disco.IsError)
{
Console.WriteLine(disco.Error);
return BadRequest();
}
var tokenClient = new TokenClient(disco.TokenEndpoint, "ro.client", "secret");
var tokenResponse = await tokenClient.RequestResourceOwnerPasswordAsync(model.Email, model.Password, "api1");
Run Code Online (Sandbox Code Playgroud)
Config.cs 类
public class Config
{
// scopes define the resources in your system
public static IEnumerable<IdentityResource> GetIdentityResources()
{
return new List<IdentityResource>
{
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
};
}
public static IEnumerable<ApiResource> GetApiResources()
{
return new List<ApiResource>
{
new ApiResource("api1", "My API")
};
} …Run Code Online (Sandbox Code Playgroud) 我的winform中有2个dateTimePickers。第一个dateTimePickers用于开始日期,另一个用于结束日期,现在我只想从这些dateTimePickers输入开始日期@结束日期,然后我会在文本框中自动获得持续时间。