Skip to content

Commit

Permalink
Merge pull request #85 from k1LoW/fix-new-client
Browse files Browse the repository at this point in the history
Need to test with authenticated clients.
  • Loading branch information
k1LoW authored May 11, 2023
2 parents 47b5155 + 3521d92 commit f5214ba
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gh/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ func newClient(ctx context.Context, owner, repo string) (*client, error) {
_, tokenSource := auth.TokenForHost(host)
token, v3ep, _, _ := factory.GetTokenAndEndpoints()
if token == "" {
slog.Info("No credentials found, access without credentials", slog.String("endpoint", v3ep), slog.String("owner", owner), slog.String("repo", repo))
slog.Info("No credentials found, access without credentials", slog.String("endpoint", v3ep), slog.String("owner", owner), slog.String("repo", repo), slog.String("host_source", hostSource))
return newNoAuthClient(ctx, owner, repo, v3ep)
}
slog.Info("Access with credentials", slog.String("endpoint", v3ep), slog.String("owner", owner), slog.String("repo", repo), slog.String("host_source", hostSource), slog.String("token_source", tokenSource))
gc, err := factory.NewGithubClient(factory.SkipAuth(true))
gc, err := factory.NewGithubClient()
if err != nil {
return nil, err
}
if _, _, err := gc.Repositories.Get(ctx, owner, repo); err != nil {
slog.Info("Authentication failed, access without credentials", slog.String("endpoint", v3ep), slog.String("owner", owner), slog.String("repo", repo), slog.String("host_source", hostSource), slog.String("token_source", tokenSource))
slog.Info("Authentication failed, access without credentials", slog.String("error", err.Error()), slog.String("endpoint", v3ep), slog.String("owner", owner), slog.String("repo", repo), slog.String("host_source", hostSource), slog.String("token_source", tokenSource))
return newNoAuthClient(ctx, owner, repo, v3ep)
}
hc, err := api.DefaultHTTPClient()
Expand Down

0 comments on commit f5214ba

Please sign in to comment.