Skip to main content



      Home
Home » Eclipse Projects » EGit / JGit » Getting Not Authrized whille Pushing
Getting Not Authrized whille Pushing [message #1872989] Tue, 03 December 2024 04:10
Eclipse UserFriend
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
Previous Topic:How to Fork and Clone Only the Default Branch Using JGit
Goto Forum:
  


Current Time: Thu May 22 03:42:51 EDT 2025

Powered by FUDForum. Page generated in 0.15167 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top