Skip to content

Commit

Permalink
github_token_validity endpoint bugfix (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
devmrfitz committed Mar 12, 2022
1 parent f9c942b commit 729fa28
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mod_auth/controllers.py
Expand Up @@ -54,6 +54,7 @@ def before_app_request() -> None:

def login_required(f: Callable) -> Callable:
"""Decorate the function to redirect to the login page if a user is not logged in."""

@wraps(f)
def decorated_function(*args, **kwargs):
if g.user is None:
Expand Down Expand Up @@ -134,10 +135,10 @@ def github_token_validity(token: str):
from run import config
github_client_id = config.get('GITHUB_CLIENT_ID', '')
github_client_secret = config.get('GITHUB_CLIENT_SECRET', '')
url = f'https://api.github.com/applications/{github_client_id}/tokens/{token}'
url = f'https://api.github.com/applications/{github_client_id}/token'
session = requests.Session()
session.auth = (github_client_id, github_client_secret)
response = session.get(url)
response = session.post(url, json={"access_token": token})

return response.status_code == 200

Expand Down

0 comments on commit 729fa28

Please sign in to comment.