简体   繁体   English

IdentityServer4:一起生成Refresh Token和ReferenceToken

[英]IdentityServer4: Generate Refresh Token and ReferenceToken Together

I'm using IdentityServer4 to secure my API-s.我正在使用 IdentityServer4 来保护我的 API-s。 I've created client with these parameters:我用这些参数创建了客户端:

AccessTokenType = 1 //Reference Token AllowOfflineAccess = 1 //Property to allowe refresh Tokens AccessTokenType = 1 //引用令牌AllowOfflineAccess = 1 //允许刷新令牌的属性

I'm calling this method to request reference Token and refresh token together:我正在调用此方法来同时请求引用令牌和刷新令牌:

            var tokenResponse = await client.RequestPasswordTokenAsync(new PasswordTokenRequest
            {
                Address = disco.TokenEndpoint,
                ClientId = ConfigurationExt.IdentityServer.ClientId,
                ClientSecret = ConfigurationExt.IdentityServer.ClientSecret,
                UserName = userName,
                Password = passwordHash,
                Parameters = parameters,
                Scope = ConfigurationExt.IdentityServer.Scope,
            });

but I'm getting refreshToken null但我得到了 refreshToken null

Is it possible to get both refresh and reference token?是否可以获得刷新和参考令牌?

As far as I know, you can only get the refresh token if you use the authorization code flow to get the tokens, not using the password grant.据我所知,如果您使用授权代码流获取令牌,则只能获取刷新令牌,而不是使用密码授予。

Also, today you should try to only use the authorization code flow or clients credentials flow.此外,今天您应该尝试仅使用授权代码流或客户端凭据流。 All other flows are deprecated if you want to follow OAuth 2.1.如果您想遵循 OAuth 2.1,则不推荐使用所有其他流程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM