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

System and Github server time difference is causing 401 #3092

Open
AnkeshThakur opened this issue Dec 11, 2024 · 0 comments
Open

System and Github server time difference is causing 401 #3092

AnkeshThakur opened this issue Dec 11, 2024 · 0 comments

Comments

@AnkeshThakur
Copy link

AnkeshThakur commented Dec 11, 2024

During execution when PyGithub needs to refresh token it ran into problem. It was running smoothly before but at that moment started giving 401 errors. What appears to be the reason for this is caused by difference between time of local system and github servers. This error came around midnight local time. Generally it is not observed but for long running processes it might be critical.

Stack trace:

File "/usr/local/lib/python3.11/site-packages/github/Requester.py", line 548, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/Requester.py", line 713, in requestJson
    return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/Requester.py", line 798, in __requestEncode
    requestHeaders["Authorization"] = f"{self.__auth.token_type} {self.__auth.token}"
                                                                  ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/Auth.py", line 328, in token
    self.__installation_authorization = self._get_installation_authorization()
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/Auth.py", line 339, in _get_installation_authorization
    return self.__integration.get_access_token(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/GithubIntegration.py", line 228, in get_access_token
    headers, response = self.__requester.requestJsonAndCheck(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/Requester.py", line 548, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/Requester.py", line 609, in __check
    raise self.createException(status, responseHeaders, data)
github.GithubException.GithubException: 401 {"message": "'Expiration time' claim ('exp') must be a numeric value representing the future time at which the assertion expires", "documentation_url": "https://docs.github.com/rest", "status": "401"}

A relevant issue issue was resolved here - octokit/auth-app.js#164

The approach identifies the time diff b/w servers and adjust exp/iat accordingly.

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

No branches or pull requests

1 participant