Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vinokurig committed Oct 23, 2023
1 parent 4661b60 commit f76061a
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class GithubPersonalAccessTokenFetcher implements PersonalAccessTokenFetc
private final OAuthAPI oAuthAPI;

/** GitHub API client. */
private final GithubApiClient githubApiClient;
private GithubApiClient githubApiClient;

/** Name of this OAuth provider as found in OAuthAPI. */
private static final String OAUTH_PROVIDER_NAME = "github";
Expand Down Expand Up @@ -223,9 +223,13 @@ public Optional<Boolean> isValid(PersonalAccessToken personalAccessToken) {

@Override
public Optional<Pair<Boolean, String>> isValid(PersonalAccessTokenParams params) {
if (!githubApiClient.isConnected(params.getScmProviderUrl())) {
LOG.debug("not a valid url {} for current fetcher ", params.getScmProviderUrl());
return Optional.empty();
if (githubApiClient == null || !githubApiClient.isConnected(params.getScmProviderUrl())) {
if (OAUTH_PROVIDER_NAME.equals(params.getScmTokenName())) {
githubApiClient = new GithubApiClient(params.getScmProviderUrl());
} else {
LOG.debug("not a valid url {} for current fetcher ", params.getScmProviderUrl());
return Optional.empty();
}
}
try {
if (params.getScmTokenName() != null && params.getScmTokenName().startsWith(OAUTH_2_PREFIX)) {
Expand Down

0 comments on commit f76061a

Please sign in to comment.