code: def parse_authorization_header(value):
      
      try:
          (auth_type, auth_info) = value.split(' ', 1)
          auth_type = auth_type.lower()
      except ValueError:
          return
      if (auth_type == 'basic'):
          try:
              decoded = base64.b64decode(auth_info).decode(
                  'utf-8')  # b64decode gives bytes in python3
              (username, password) = decoded.split(':', 1)
          except (ValueError, TypeError):  # py3, py2
              return
          return {'type': 'basic', 'username': username, 'password': password}
      elif (auth_type == 'digest'):
          try:
              auth_map = parse_keqv_list(parse_http_list(auth_info))
          except ValueError:
              return
          logging.debug(auth_map)
          for key in 'username', 'realm', 'nonce', 'uri', 'response':
              if key not in auth_map:
                  return
          if 'qop' in auth_map and ('nc' not in auth_map or 'cnonce' not in auth_map):
              return
          auth_map['type'] = 'digest'
          return auth_map
      else:
          # unknown auth type
          return
docs: Parse the Authenticate header.
  
      Returns nothing on failure, opts hash on success with type='basic' or 'digest'
      and other params.
  
      <http://nullege.com/codes/search/werkzeug.http.parse_authorization_header>
      <http://stackoverflow.com/questions/1349367/parse-an-http-request-authorization-header-with-python>
      <http://bugs.python.org/file34041/0001-Add-an-authorization-header-to-the-initial-request.patch>