Skip to content

Commit 94b5ed8

Browse files
committed
🔧 Fixed null credentials when no token is provided for GH client
1 parent 9365812 commit 94b5ed8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

code/SimpleRemoteGitRepoBackup.Console/Program.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ await Parser.Default.ParseArguments<CommandOptions>(args)
7575
{
7676
var githubLogger = scope.ServiceProvider.GetRequiredService<ILogger<GitHubRepositoryProvider>>();
7777

78+
var client = new GitHubClient(new ProductHeaderValue("CodeBackupApp"));
79+
7880
// If we don't provide any credentials for GH then we are limited
7981
// in accessing only public repositories and have very low rate limits.
8082
var credentials = string.IsNullOrWhiteSpace(options.Token)
@@ -85,11 +87,11 @@ await Parser.Default.ParseArguments<CommandOptions>(args)
8587
{
8688
logger.LogWarning("⚠️⚠️⚠️ No GitHub Personal Access Token provided. Only public repositories can be accessed, and rate limits will be low.");
8789
}
88-
89-
var client = new GitHubClient(new ProductHeaderValue("CodeBackupApp"))
90+
91+
if (credentials != null)
9092
{
91-
Credentials = credentials
92-
};
93+
client.Credentials = credentials;
94+
}
9395

9496
var fileSystem = new FileSystemWrapper();
9597

0 commit comments

Comments
 (0)