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

Enviroment variables only #27

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions ImplementationTools/GoogleSheets.Common/GoogleSheetsExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public async static System.Threading.Tasks.Task WriteToSpreadsheetAsync(string a
// The file token.json stores the user`s access and refresh tokens, and is created
// automatically when the authorization flow completes for the first time.
ClientSecrets cs = new ClientSecrets();
cs.ClientId = "1079571407435-h3fragu093p2gvpsjrvjuc28683roe26.apps.googleusercontent.com";
cs.ClientSecret = "Rz95mxPZict94BZaTl9vSww0";
cs.ClientId = Environment.GetEnvironmentVariable("ClientId");
cs.ClientSecret = Environment.GetEnvironmentVariable("ClientSecret");
UserCredential credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
cs,
Scopes,
Expand Down
15 changes: 15 additions & 0 deletions ImplementationTools/ServiceDirectoryExporter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public static void Main(string[] args)
var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
try
{
DotNetEnv.Env.TraversePath().Load();
IConfigurationRoot config = new ConfigurationBuilder()
.AddEnvironmentVariables()
.Build();
logger.Debug("init main");
CreateHostBuilder(args).Build().Run();
}
Expand All @@ -35,6 +39,17 @@ public static void Main(string[] args)

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
if (config is null)
{
throw new ArgumentNullException(nameof(config));
}
else
{
IConfigurationBuilder configurationBuilder = config.AddEnvironmentVariables();
}
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>().ConfigureLogging(logging =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<PackageReference Include="Google.Apis.Auth.AspNetCore3" Version="1.49.0" />
<PackageReference Include="NLog" Version="4.7.8" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.11.0" />
<PackageReference Include="DotNetEnv" Version="2.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions ImplementationTools/ServiceDirectoryExporter/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Google.Apis.Auth.AspNetCore3;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Builder;
Expand Down Expand Up @@ -35,8 +36,8 @@ public void ConfigureServices(IServiceCollection services)
o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
}).AddCookie().AddGoogleOpenIdConnect(options =>
{
options.ClientId = "1079571407435-e83hm1n7l8pg31936obqip62lh1kvie7.apps.googleusercontent.com";
options.ClientSecret = "Y9OGaTm4eOyyFM0nNjeY2PPU";
options.ClientId = System.Environment.GetEnvironmentVariable("ClientId");
options.ClientSecret = System.Environment.GetEnvironmentVariable("ClientSecret");
});
}

Expand Down