ZhouliProject/Zhouli.XUnitTest/UnitTest1.cs
(完整代码) 1KBusing IdentityModel.Client;
using System;
using System.Net.Http;
using Xunit;
namespace Zhouli.XUnitTest
{
public class UnitTest1
{
[Fact]
public async void Test1Async()
{
string strAccessToken = "";
{
var client = new HttpClient();
var response = client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
{
Address = "http://localhost:5000/connect/token",
ClientId = "zhouli",
ClientSecret = "991022",
Scope = "Zhouli.FileService"
});
strAccessToken = response.Result.AccessToken;
}
{
var client = new HttpClient();
client.SetBearerToken(strAccessToken);
var response = client.GetAsync("http://localhost:5001/Blog");
if (!response.Result.IsSuccessStatusCode)
{
Console.WriteLine(response.Result.StatusCode);
}
else
{
var content = await response.Result.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。