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)
| 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 |
nothing calls this directly
no test coverage detected