Jira DVCS synchronization fails with the "Invalid credentials" error
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Fisheye および Crucible は除く
要約
A DVCS GitHub Enterprise repository synchronization might fail with the error "Invalid credentials, please reset OAuth settings" for a number of reasons.
診断
In the atlassian-jira.log
we can observe the error Bad credentials (401)
, as in the example:
2020-09-09 18:54:55,761 http-nio-x.x.x.x-8081-exec-80 url:/rest/bitbucket...epository/12/sync INFO anonymous 1134x10999251x11 kjlbkc x.x.x.x,x.x.x.x /rest/bitbucket/1.0/repository/12/sync [c.a.j.p.d.r.external.v1.RepositoryResource] Postcommit hook started synchronization for repository [12].
2020-09-09 18:54:55,848 http-nio-x.x.x.x-8081-exec-80 url:/rest/bitbucket...epository/12/sync INFO anonymous 1134x10999251x11 kjlbkc x.x.x.x,x.x.x.x /rest/bitbucket/1.0/repository/12/sync [c.a.j.p.d.spi.github.GithubCommunicator] Can not obtain branches list from repository [ MyREPO ] org.eclipse.egit.github.core.client.RequestException: Bad credentials (401)
at org.eclipse.egit.github.core.client.GitHubClient.createException(GitHubClient.java:552)
at org.eclipse.egit.github.core.client.GitHubClient.get(GitHubClient.java:740)
at org.eclipse.egit.github.core.client.PageIterator.next(PageIterator.java:173)
at org.eclipse.egit.github.core.service.GitHubService.getAll(GitHubService.java:151)
at org.eclipse.egit.github.core.service.GitHubService.getAll(GitHubService.java:135)
at org.eclipse.egit.github.core.service.RepositoryService.getBranches(RepositoryService.java:785)
at com.atlassian.jira.plugins.dvcs.spi.github.GithubCommunicator.getBranches(GithubCommunicator.java:515)
at com.atlassian.jira.plugins.dvcs.spi.github.GithubCommunicator.startSynchronisation(GithubCommunicator.java:604)
at com.atlassian.jira.plugins.dvcs.service.remote.CachingCommunicator.startSynchronisation(CachingCommunicator.java:98)
at com.atlassian.jira.plugins.dvcs.sync.impl.DefaultSynchronizer.doSync(DefaultSynchronizer.java:173)
at com.atlassian.jira.plugins.dvcs.service.RepositorySyncServiceImpl.doSync(RepositorySyncServiceImpl.java:440)
Cause 1 - lack of permissions
If the account used doesn't have access to a repository, we'll face the invalid credentials error.
ソリューション 1
Grant access to the GitHub account.
Cause 2 - OAuth token revoked
If for any reason, the token is revoked, you will face this error.
ソリューション 2
Reset the OAuth Settings:
- Click on the ellipsis (...) icon and select the Reset OAuth Settings option
- Click on Edit
- Enter the Key and Secret and click on Regenerate Access Token
Cause 3 - More than 10 organizations
If you have more than 10 organizations for the same account in GitHub Enterprise, you might experience the following:
- See the "Invalid credentials" error
- Reset the OAuth settings
- The sync runs successfully
- After some hours, the error happens again
ソリューション 3
In this case, then you have to set up the OAuth App via the Organization and not via the Service Account.
To do this, the Service Account needs to have Owner access to the Organization being linked.
参照:
- https://docs.github.com/en/free-pro-team@latest/github/setting-up-and-managing-organizations-and-teams/permission-levels-for-an-organization
- https://docs.github.com/en/free-pro-team@latest/developers/apps/troubleshooting-oauth-app-access-token-request-errors