Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Expired token unable to refresh #68

Open
bguedel opened this issue Jul 29, 2021 · 3 comments
Open

[Bug] Expired token unable to refresh #68

bguedel opened this issue Jul 29, 2021 · 3 comments

Comments

@bguedel
Copy link

bguedel commented Jul 29, 2021

2021-07-29 19:44:31.615  INFO [my-bot,1efb3e9c675e3506,1efb3e9c675e3506] 1 --- [nio-8080-exec-7] c.s.github.v3.clients.GitHubClient       : Github token for installation 1234 is either expired or null. Trying to get a new one.
--
2021-07-29 19:44:31.615  INFO [my-bot,1efb3e9c675e3506,1efb3e9c675e3506] 1 --- [nio-8080-exec-7] c.s.github.v3.clients.GitHubClient       : Got JWT Token. Now getting Github access_token for installation 1234
2021-07-29 19:44:31.619 ERROR [my-bot,a1558e2c87f905cd,a1558e2c87f905cd] 1 --- [nio-8080-exec-5] c.comp.path.WebhookErrorHandler  : error processing request: (Could not generate access token for github app)
java.lang.RuntimeException: Could not generate access token for github app
...
Caused by: java.lang.Exception: Got non-2xx status 401 when getting an access token from GitHub: Unauthorized
    at com.spotify.github.v3.clients.GitHubClient.generateInstallationToken(GitHubClient.java:607) ~[github-client-0.0.25.jar:0.0.25]
    at com.spotify.github.v3.clients.GitHubClient.getInstallationToken(GitHubClient.java:581) ~[github-client-0.0.25.jar:0.0.25]
    at com.spotify.github.v3.clients.GitHubClient.getAuthorizationHeader(GitHubClient.java:560) ~[github-client-0.0.25.jar:0.0.25]

on restart of the application; everything works fine.

@bguedel
Copy link
Author

bguedel commented Aug 12, 2021

Ill keep an eye on this. I think #70 might have fixed this? This error often happens after the connection leaked issue happens.

@bguedel
Copy link
Author

bguedel commented Aug 13, 2021

#70 did NOT fix this. Still seeing it.

doesnt happen on every request. so dont really know what it could be.

@bguedel
Copy link
Author

bguedel commented Aug 16, 2021

Here are my thoughts

https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app

# Generate the JWT
payload = {
  # issued at time, 60 seconds in the past to allow for clock drift
  iat: Time.now.to_i - 60,

however in this code we see

so i am wondering if the fix is simply to remove 60 seconds.

bguedel added a commit to bguedel/github-java-client that referenced this issue Aug 17, 2021
fixes spotify#68

per example in related issue; time sync issue can occur when setting issued at to be the current time. This sets the issued at to be 1 minute earlier to avoid this.

Tested locally for 2 days with no issues.
@bguedel bguedel mentioned this issue Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant