def GitHub_login(*, username=None, password=None, OTP=None, headers=None):
if not username:<EOL><INDENT>username = input("<STR_LIT>")<EOL><DEDENT>if not password:<EOL><INDENT>password = getpass("<STR_LIT>".format(username=username))<EOL><DEDENT>headers = headers or {}<EOL>if OTP:<EOL><INDENT>headers['<STR_LIT>'] = OTP<EOL><DEDENT>auth = HTTPBasicAuth(username, password)<EOL>r = requests.get('<STR_LIT>', auth=auth, headers=headers)<EOL>if r.status_code == <NUM_LIT>:<EOL><INDENT>two_factor = r.headers.get('<STR_LIT>')<EOL>if two_factor:<EOL><INDENT>if OTP:<EOL><INDENT>print(red("<STR_LIT>"))<EOL><DEDENT>auth_header = base64.urlsafe_b64encode(bytes(username + '<STR_LIT::>' + password, '<STR_LIT:utf8>')).decode()<EOL>login_kwargs = {'<STR_LIT>': None, '<STR_LIT>': {'<STR_LIT>': '<STR_LIT>'.format(auth_header)}}<EOL>try:<EOL><INDENT>generate_GitHub_token(**login_kwargs)<EOL><DEDENT>except (requests.exceptions.HTTPError, GitHubError):<EOL><INDENT>pass<EOL><DEDENT>print("<STR_LIT>", two_factor.split('<STR_LIT:;>')[<NUM_LIT:1>].strip())<EOL>OTP = input("<STR_LIT>")<EOL>return GitHub_login(username=username, password=password, OTP=OTP, headers=headers)<EOL><DEDENT>raise AuthenticationFailed("<STR_LIT>")<EOL><DEDENT>GitHub_raise_for_status(r)<EOL>return {'<STR_LIT>': auth, '<STR_LIT>': headers}<EOL>
Login to GitHub.

If no username, password, or OTP (2-factor authentication code) are
provided, they will be requested from the command line.

Returns a dict of kwargs that can be passed to functions that require
authenticated connections to GitHub.