MCPcopy
hub / github.com/gitcoinco/web / is_github_token_valid

Method is_github_token_valid

app/dashboard/models.py:2011–2033  ·  view source on GitHub ↗

Check whether or not a Github OAuth token is valid. Args: access_token (str): The Github OAuth token. Returns: bool: Whether or not the provided OAuth token is valid.

(self)

Source from the content-addressed store, hash-verified

2009
2010
2011 def is_github_token_valid(self):
2012 """Check whether or not a Github OAuth token is valid.
2013
2014 Args:
2015 access_token (str): The Github OAuth token.
2016
2017 Returns:
2018 bool: Whether or not the provided OAuth token is valid.
2019
2020 """
2021 if not self.github_access_token:
2022 return False
2023
2024 _params = build_auth_dict(self.github_access_token)
2025 url = TOKEN_URL.format(**_params)
2026 response = requests.get(
2027 url,
2028 auth=(_params['client_id'], _params['client_secret']),
2029 headers=HEADERS)
2030
2031 if response.status_code == 200:
2032 return True
2033 return False
2034
2035 def __str__(self):
2036 return self.handle

Callers

nothing calls this directly

Calls 1

build_auth_dictFunction · 0.90

Tested by

no test coverage detected