Get all email addresses associated with the github profile. Args: oauth_token (str): The Github OAuth2 token to use for authentication. Returns: list of str: All of the user's associated email from git.
(oauth_token)
| 334 | |
| 335 | |
| 336 | def get_github_emails(oauth_token): |
| 337 | """Get all email addresses associated with the github profile. |
| 338 | |
| 339 | Args: |
| 340 | oauth_token (str): The Github OAuth2 token to use for authentication. |
| 341 | |
| 342 | Returns: |
| 343 | list of str: All of the user's associated email from git. |
| 344 | |
| 345 | """ |
| 346 | emails = [] |
| 347 | headers = dict({'Authorization': f'token {oauth_token}'}, **JSON_HEADER) |
| 348 | response = requests.get('https://api.github.com/user/emails', headers=headers) |
| 349 | |
| 350 | if response.status_code == 200: |
| 351 | email_data = response.json() |
| 352 | for email in email_data: |
| 353 | email_address = email.get('email') |
| 354 | if email_address and 'noreply.github.com' not in email_address: |
| 355 | emails.append(email_address) |
| 356 | |
| 357 | return emails |
| 358 | |
| 359 | |
| 360 | def get_emails_master(username): |
no outgoing calls