Hi
- I am trying to perform a push operation using the OAuth2 token from GitHub App
- The token is valid, with all the necessary permissions granted on GitHub
- I'm using a public repository that belongs to the same user that owns the token
- Clone, pull, commit and status operations are working fine
Error Message
Quote:
Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/mytest4mail03/sample01.git: not authorized
This is the code I'm trying to run:
try (Git git = Git.open(new File("path_to_git"))) {
CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider("MY_TOKEN", "");
Iterable<PushResult> pushResults =
git.push()
.setCredentialsProvider(credentialsProvider)
.call();
}
I also tried the workaround below (but I get an error saying credentialsProvider is missing if set it it also fail with the same initial message) :
git.push()
.setTransportConfigCallback(
transport -> {
if (transport instanceof TransportHttp transportHttp) {
transportHttp.setAdditionalHeaders(
Map.of("Authorization", "Bearer " + "mExvIViQ/o8ENPnndtNIzGcwEjh8BRlKr6JHGHvzNVsUrgyUGkFWt+fRfAxFgA/v"));
}
})
.setPushAll()
.call();
Thanks