Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the example compatible to the current api #563

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion dotnet/Vaas/src/Vaas/VaasFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Net.Http;
using Vaas.Authentication;

Expand Down
21 changes: 17 additions & 4 deletions dotnet/Vaas/test/TestFiles/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Vaas;
using Vaas.Authentication;

if (args.Length == 0)
{
Expand All @@ -11,11 +12,11 @@
foreach (var path in args)
{
Console.WriteLine($"Testing {path}");
var verdict = await vaas.ForFileAsync(path);
var verdict = await vaas.ForFileAsync(path, CancellationToken.None);
Console.WriteLine($"Tested {path}: Verdict {verdict}");
}

static async Task<Vaas.Vaas> AuthenticateWithCredentials()
static async Task<Vaas.IVaas> AuthenticateWithCredentials()
{
DotNetEnv.Env.NoClobber().TraversePath().Load();
var url = DotNetEnv.Env.GetString(
Expand All @@ -26,8 +27,20 @@
"https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"));
var clientId = DotNetEnv.Env.GetString("CLIENT_ID");
var clientSecret = DotNetEnv.Env.GetString("CLIENT_SECRET");
var vaas = new Vaas.Vaas(new VaasOptions() { UseCache = false });
await vaas.ConnectWithCredentials(clientId, clientSecret, tokenEndpoint, url);

var vaas = VaasFactory.Create(new VaasOptions()
{
Url = new Uri(url),
TokenUrl = tokenEndpoint,
Credentials = new TokenRequest
{
GrantType = GrantType.ClientCredentials,
ClientId = clientId,
ClientSecret = clientSecret,
}
});

await vaas.Connect(CancellationToken.None);
Console.WriteLine($"Connected to Vaas {url}", url);
return vaas;
}
5 changes: 4 additions & 1 deletion dotnet/Vaas/test/TestFiles/TestFiles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

<ItemGroup>
<PackageReference Include="DotNetEnv" Version="3.1.1" />
<PackageReference Include="Vaas" Version="[1.0,2.0)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Vaas\Vaas.csproj" />
</ItemGroup>

</Project>
Loading