code: def parse_signed_request(signed_request, app_secret):
      
      try:
          encoded_sig, payload = map(str, signed_request.split(".", 1))
  
          sig = base64.urlsafe_b64decode(
              encoded_sig + "=" * ((4 - len(encoded_sig) % 4) % 4)
          )
          data = base64.urlsafe_b64decode(
              payload + "=" * ((4 - len(payload) % 4) % 4)
          )
      except IndexError:
          # Signed request was malformed.
          return False
      except TypeError:
          # Signed request had a corrupted payload.
          return False
      except binascii.Error:
          # Signed request had a corrupted payload.
          return False
  
      data = json.loads(data.decode("ascii"))
      if data.get("algorithm", "").upper() != "HMAC-SHA256":
          return False
  
      # HMAC can only handle ascii (byte) strings
      # https://bugs.python.org/issue5285
      app_secret = app_secret.encode("ascii")
      payload = payload.encode("ascii")
  
      expected_sig = hmac.new(
          app_secret, msg=payload, digestmod=hashlib.sha256
      ).digest()
      if sig != expected_sig:
          return False
  
      return data
docs: Return dictionary with signed request data.
  
      We return a dictionary containing the information in the
      signed_request. This includes a user_id if the user has authorised
      your application, as well as any information requested.
  
      If the signed_request is malformed or corrupted, False is returned.