我找到了一种内省offline_access 范围令牌的方法。我希望这可以帮助像我一样坚持的人。说一下我的代码
public static IEnumerable<ApiResource> GetApis()
{
return new List<ApiResource>
{
new ApiResource("api1", "My API")
{
ApiSecrets = { new Secret("secret".Sha256()) }
}
};
}
我的客户代码是
public static IEnumerable<Client> GetClients()
{
return new List<Client>
{
// resource owner password grant client
new Client
{
ClientId = "ro.client",
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
ClientSecrets =
{
new Secret("secret".Sha256())
},
AllowedScopes = new List<string>
{
"api1",
IdentityServerConstants.StandardScopes.OfflineAccess,
},
AllowOfflineAccess = true,
AccessTokenType = AccessTokenType.Reference, // revocation endpoint work with reference access token only
}
};
}
请求访问令牌时,将 api1 和 offline_access 一起包含,
请求刷新令牌时,
进行自省时,注意用户名api1和密码secret将在基本授权期间使用
在撤销引用令牌或刷新令牌时,请注意用户名 ro.client 和密码 secret 将在基本授权期间使用,