-
-
Save gastaldi/3ad56b07dcadfd7c055272e9956ba4d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///usr/bin/env jbang "$0" "$@" ; exit $? | |
import java.io.IOException; | |
import java.net.URI; | |
import java.net.http.HttpClient; | |
import java.net.http.HttpRequest; | |
import java.net.http.HttpResponse; | |
import java.nio.charset.StandardCharsets; | |
import java.util.Base64; | |
import static java.lang.System.out; | |
public class fetch { | |
private static final String URL = "https://maven.pkg.github.com/gsmet/github-action-playground/io/github/gsmet/github-action-playground/1.0.0-SNAPSHOT/github-action-playground-1.0.0-20220722.093742-12.jar"; | |
public static void main(String... args) throws IOException, InterruptedException { | |
if (args.length != 1) { | |
out.println("Usage: fetch <github PAT token with read-packages>"); | |
return; | |
} | |
HttpClient httpClient = HttpClient.newHttpClient(); | |
HttpRequest request = HttpRequest.newBuilder() | |
.uri(URI.create(URL)) | |
.header("Authorization", | |
"Basic " + Base64.getEncoder().encodeToString((args[0] + ":").getBytes(StandardCharsets.UTF_8))) | |
.build(); | |
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); | |
System.out.println("java: " + response); | |
} | |
} |
Author
gastaldi
commented
Aug 22, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment