1313import org .jspecify .annotations .Nullable ;
1414import org .slf4j .Logger ;
1515import org .slf4j .LoggerFactory ;
16+ import org .springframework .beans .factory .annotation .Value ;
1617import org .springframework .http .ResponseEntity ;
1718import org .springframework .stereotype .Service ;
1819import org .springframework .web .client .RestClient ;
2223public class GitHubClient {
2324
2425 private final static Logger log = LoggerFactory .getLogger (GitHubClient .class );
25- public static final String GITHUB_TOKEN = "GITHUB_TOKEN" ;
2626 public static final String GITHUB_API_URL = "https://api.github.com" ;
2727 public static final String HTTP_ACCEPT = "Accept" ;
2828 public static final String GITHUB_V_3_JSON = "application/vnd.github.v3+json" ;
@@ -35,11 +35,10 @@ public class GitHubClient {
3535 * Default constructor that initializes the GitHub client with the base URL and headers.
3636 * It retrieves the GitHub token from the environment variable GITHUB_TOKEN.
3737 */
38- public GitHubClient () {
38+ public GitHubClient (@ Value ( "${github.token}" ) String githubToken ) {
3939 Builder builder = RestClient .builder ()
4040 .baseUrl (GITHUB_API_URL )
4141 .defaultHeader (HTTP_ACCEPT , GITHUB_V_3_JSON );
42- final String githubToken = System .getenv ("GITHUB_TOKEN" );
4342 if (githubToken != null && !githubToken .isBlank ()) {
4443 log .info ("Using GitHub token for API authentication" );
4544 builder = builder .defaultHeader ("Authorization" , "Bearer " + githubToken );
0 commit comments