github-api
github-api copied to clipboard
GHMyself fails with Github enterprise
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,
What version of GitHub Enterprise are you using?
I assume you're passing the PAT in the password parameter there?
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.
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)