Sau*_*ani 6 c# asp.net-mvc identitymodel
我正在使用 IdentityModel 4.1.1 for OAuth2.0 现在我在创建 TokenClient 实例期间卡住了,该实例用于使用刷新令牌请求新的访问令牌。
这是我正在做的代码,
TokenClientOptions clientOptions = new TokenClientOptions();
clientOptions.ClientId = _configDetails.Where(x => x.Key == "ClientId").Select(x => x.Value).FirstOrDefault().ToString();
clientOptions.ClientSecret = _configDetails.Where(x => x.Key == "ClientSecret").Select(x => x.Value).FirstOrDefault().ToString();
//Create token client object object
var tokenClient = new TokenClient("?",clientOptions); //Here I need help what I have to pass as first parameter?
TokenResponse refereshtokenCallResponse = await tokenClient.RequestRefreshTokenAsync(token.RefreshToken);
Run Code Online (Sandbox Code Playgroud)
下面是IdentityModel4.1.1 pkg提供的TokenClient类,
public class TokenClient
{
public TokenClient(HttpMessageInvoker client, TokenClientOptions options);
public TokenClient(Func<HttpMessageInvoker> client, TokenClientOptions options);
public Task<TokenResponse> RequestAuthorizationCodeTokenAsync(string code, string redirectUri, string codeVerifier = null, IDictionary<string, string> parameters = null, CancellationToken cancellationToken = default(CancellationToken));
public Task<TokenResponse> RequestClientCredentialsTokenAsync(string scope = null, IDictionary<string, string> parameters = null, CancellationToken cancellationToken = default(CancellationToken));
public Task<TokenResponse> RequestDeviceTokenAsync(string deviceCode, IDictionary<string, string> parameters = null, CancellationToken cancellationToken = default(CancellationToken));
public Task<TokenResponse> RequestPasswordTokenAsync(string userName, string password = null, string scope = null, IDictionary<string, string> parameters = null, CancellationToken cancellationToken = default(CancellationToken));
public Task<TokenResponse> RequestRefreshTokenAsync(string refreshToken, string scope = null, IDictionary<string, string> parameters = null, CancellationToken cancellationToken = default(CancellationToken));
public Task<TokenResponse> RequestTokenAsync(string grantType, IDictionary<string, string> parameters = null, CancellationToken cancellationToken = default(CancellationToken));
}
Run Code Online (Sandbox Code Playgroud)
正如上面的类表示需要传递 HttpMessageInvoker 作为第一个参数,但我对此完全茫然。我还提到了 IdentityModel文件,但没有得到任何线索
小智 4
您必须将 HttpClient 作为参数传递,并带有已设置的 BaseUrl。
查看GitHub上的测试,看看它是如何构建的。
编辑:为了消除任何混淆,HttpClient将 HttpMessageInvoker 作为基类。
| 归档时间: |
|
| 查看次数: |
6646 次 |
| 最近记录: |