mirror of
https://github.com/microsoft/autogen.git
synced 2026-04-20 03:02:16 -04:00
* big bang gitub workflows * add missing settings in local.settings.json * config refactor * fix devlead plan response * swap cosmos to table storage for metadata storage * unify config via options * azd-ify WIP * add qdrant bicep WIP * working azd provision setup * consolidate SK version in projects * replace localhost :) * add fqdn to options * httpclient fixes * add managed identity to the function and assign contrib role * qdrant endpoint setting * add container instances cleanup code + wait on termination to upload to Github * formatting fixes * add tables in bicep * local getting started WIP * add azure setup instructions * add the load-waf bits * docs WIP --------- Co-authored-by: Kosta Petan <Kosta.Petan@microsoft.com>
36 lines
1.4 KiB
C#
36 lines
1.4 KiB
C#
using Microsoft.Extensions.Options;
|
|
using Octokit;
|
|
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2007: Do not directly await a Task", Justification = "Durable functions")]
|
|
public class GithubService
|
|
{
|
|
private readonly GithubOptions _githubSettings;
|
|
|
|
public GithubService(IOptions<GithubOptions> ghOptions)
|
|
{
|
|
_githubSettings = ghOptions.Value;
|
|
}
|
|
public async Task<GitHubClient> GetGitHubClient()
|
|
{
|
|
// Use GitHubJwt library to create the GitHubApp Jwt Token using our private certificate PEM file
|
|
var generator = new GitHubJwt.GitHubJwtFactory(
|
|
new GitHubJwt.StringPrivateKeySource(_githubSettings.AppKey),
|
|
new GitHubJwt.GitHubJwtFactoryOptions
|
|
{
|
|
AppIntegrationId = _githubSettings.AppId, // The GitHub App Id
|
|
ExpirationSeconds = 600 // 10 minutes is the maximum time allowed
|
|
}
|
|
);
|
|
|
|
var jwtToken = generator.CreateEncodedJwtToken();
|
|
var appClient = new GitHubClient(new ProductHeaderValue("SK-DEV-APP"))
|
|
{
|
|
Credentials = new Credentials(jwtToken, AuthenticationType.Bearer)
|
|
};
|
|
var response = await appClient.GitHubApps.CreateInstallationToken(_githubSettings.InstallationId);
|
|
return new GitHubClient(new ProductHeaderValue($"SK-DEV-APP-Installation{_githubSettings.InstallationId}"))
|
|
{
|
|
Credentials = new Credentials(response.Token)
|
|
};
|
|
}
|
|
} |