github-api icon indicating copy to clipboard operation
github-api copied to clipboard

GHMyself fails with Github enterprise

Open familrodrigues opened this issue 3 years ago • 2 comments

Trying to connect to Github enterprise with User name & PAT token. GHMyself throws a 401 unauthorized error

To Reproduce Steps to reproduce the behavior:

GitHub github = GitHub.connectToEnterpriseWithOAuth(gitURL, aUsername, aPassword);
GHMyself aUser = github.getMyself();

Issue seems to be in GHMyself u = retrieve().to("/user", GHMyself.class); Expects the token as part of this API call

Expected behavior Would need GHmyself to be successfully populated.

Additional context Connect to Git hub enterprise with PAT token. The same code works fine with Github,

familrodrigues avatar Sep 28 '22 16:09 familrodrigues

What version of GitHub Enterprise are you using? I assume you're passing the PAT in the password parameter there?

bitwiseman avatar Sep 28 '22 20:09 bitwiseman

Hi Thanks for getting back.. We are using the GitHUb SAAS version. Yes the PAT is passed in the password parameter.. GitHub.connectToEnterpriseWithOAuth(gitURL, aUsername, aPassword); GitURL - https://api.github.com/ aUsername - Github username aPassword - PAT token

this statement executes correctly and i am able to view the results. Github-1

However when i execute the next statement, GHMyself aUser = github.getMyself(); i get the below error. Caused by: org.kohsuke.github.HttpException: Server returned HTTP response code: 401, message: 'Unauthorized' for URL: https://api.github.com/user at org.kohsuke.github.Requester.parse(Requester.java:646)

familrodrigues avatar Sep 29 '22 07:09 familrodrigues