35 lines
950 B
C#
35 lines
950 B
C#
|
using IdentityModel.Client;
|
|||
|
using System;
|
|||
|
using System.Net.Http;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace TestAppRuna.TokenGenerator
|
|||
|
{
|
|||
|
class Program
|
|||
|
{
|
|||
|
static void Main(string[] args)
|
|||
|
{
|
|||
|
Startup().Wait();
|
|||
|
}
|
|||
|
static async Task Startup()
|
|||
|
{
|
|||
|
var clientID = "testappruna";
|
|||
|
var clientSecret = "1071ccf6-1ea7-4d75-b6e7-28846e386eb5";
|
|||
|
|
|||
|
var client = new HttpClient();
|
|||
|
var disco = await client.GetDiscoveryDocumentAsync("https://accounts.nanao.moe/auth/realms/staging");
|
|||
|
|
|||
|
var response = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
|
|||
|
{
|
|||
|
Address = disco.TokenEndpoint,
|
|||
|
|
|||
|
ClientId = clientID,
|
|||
|
ClientSecret = clientSecret,
|
|||
|
Scope = "customer-api"
|
|||
|
});
|
|||
|
|
|||
|
Console.WriteLine(response.AccessToken);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|