Skip to content

Commit

Permalink
Encode exp as integer in app jwt.
Browse files Browse the repository at this point in the history
Fixes 401 errors in current github api due to use of floating point,
rather than integer value in app jwt.

Github, y u change api behavior? ಠ_ಠ
  • Loading branch information
asford committed Aug 14, 2018
1 parent 476589b commit 3a501f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions git_credential_github_app_auth/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@

def app_session_for(app: AppIdentity) -> requests.Session:
session = requests.Session()
session.headers.update({
headers = {
"Authorization":"Bearer %s" % app.jwt(),
"Accept": "application/vnd.github.machine-man-preview+json"
})
}
logger.debug(
f"app_session_for: "
f"-H 'Authorization: { headers['Authorization'] }' "
f"-H 'Accept: { headers['Accept'] }'"
)
session.headers.update(headers)

return session

Expand Down
4 changes: 2 additions & 2 deletions git_credential_github_app_auth/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def jwt(self) -> str:
"""
issue_time = time.time() - 1
payload = dict(
iat= issue_time,
exp= issue_time + (10 * 60),
iat= int(issue_time),
exp= int(issue_time + (10 * 60)),
iss= self.app_id
)

Expand Down

0 comments on commit 3a501f8

Please sign in to comment.