parameters: ()
return_statement: return auth
docstring: Construct a basic auth object from a username and password
docstring_summary: Construct a basic auth object from a username and password
docstring_tokens: Construct a basic auth object from a username and password
function: def get_auth():
      """
      Construct a basic auth object from a username and password
      """
      username = raw_input('Username: ')
      password = getpass.getpass('Password: ')
  
      auth = HTTPBasicAuth(username, password)
  
      # Test auth by requesting repo events
      response = requests.get('https://api.github.com/notifications', auth=auth)
  
      if response.status_code == 401:
          otp = response.headers.get('X-Github-OTP')
          if otp and otp.startswith('required'):
              logger.warn('You are using 2-factor authentication. Please create a personal access token at https://github.com/settings/applications#personal-access-tokens and provide it here')
              access_token = raw_input('Personal access token: ')
              auth = HTTPBasicAuth(access_token, '')
          else:
              raise Exception('Invalid username or password')
  
      return auth
function_tokens: def get_auth ( ) : username = raw_input ( 'Username: ' ) password = getpass . getpass ( 'Password: ' ) auth = HTTPBasicAuth ( username , password ) # Test auth by requesting repo events response = requests . get ( 'https://api.github.com/notifications' , auth = auth ) if response . status_code == 401 : otp = response . headers . get ( 'X-Github-OTP' ) if otp and otp . startswith ( 'required' ) : logger . warn ( 'You are using 2-factor authentication. Please create a personal access token at https://github.com/settings/applications#personal-access-tokens and provide it here' ) access_token = raw_input ( 'Personal access token: ' ) auth = HTTPBasicAuth ( access_token , '' ) else : raise Exception ( 'Invalid username or password' ) return auth