'an internal error occurred' while using roblox api (PYTHON)

I been trying to learn how to use the roblox api using python but i keep getting error ‘an internal error occurred’ with https://apis.roblox.com/challenge/v1/continue I been trying to look everywhere but I cant find what im doing wrong
SCRIPT:

def request_cookie(cookie):
  auth_response = requests.post("https://auth.roblox.com/v1/logout", headers = {"cookie": f".ROBLOSECURITY={cookie}"})
  if auth_response.status_code == 403:
    if "x-csrf-token" in auth_response.headers:
        token = auth_response.headers["x-csrf-token"]
        headers = {
        "cookie": f".ROBLOSECURITY={cookie}",
        "x-csrf-token": token
                  }
        return headers

headers = request_cookie(cookie)

response = requests.get('https://users.roblox.com/v1/users/authenticated', headers=headers)

if response.status_code == 200:
    user_info = response.json()
    USER_ID = user_info.get('id')
else:
    print("Failed to retrieve user ID.")


data = {
"password": Password,
"reauthenticationToken": "string"
}
message_response = requests.post(f"https://twostepverification.roblox.com/v1/users/{USER_ID}/configuration/authenticator/disable", headers=headers, json=data)
Status = message_response.json()
print(Status)

try:
  rblx_challenge_id = message_response.headers['Rblx-Challenge-Id']  
  challenge_id = json.loads(base64.b64decode(message_response.headers['rblx-challenge-metadata']).decode('utf-8')).get("challengeId")
  print(challenge_id)
  print(rblx_challenge_id)
except:
  pass
if "error" in message_response.text:
  data = {
"challengeId": challenge_id,
"actionType": 8,
"code": Recovery_code
}
  message_response = requests.post(f"https://twostepverification.roblox.com/v1/users/{USER_ID}/challenges/recovery-codes/verify", headers=headers, json=data)
  verificationToken = message_response.json()['verificationToken']
  print(verificationToken)
  
  challengeMetadata = "{\"verificationToken\":\"EXAMPLE\",\"rememberDevice\":false,\"challengeId\":\"EXAMPLE2\",\"actionType\":\"GenericWithRecoveryCodes\"}".replace("EXAMPLE", verificationToken).replace("EXAMPLE2", challenge_id)
  
  data = {
  "challengeId": rblx_challenge_id,
  "challengeMetadata": challengeMetadata,
  "challengeType": "twostepverification"
  }
  print(data)
  
  message_response = requests.post(f"https://apis.roblox.com/challenge/v1/continue", headers=headers, json=data)

  print(message_response.json())

Terminal:

{'errors': [{'code': 0, 'message': 'Challenge is required to authorize the request'}]}
e84d648e-5734-4922-8b75-797d0d102893
0279b094-07bf-425e-9657-73be34fa2ee9
wC0TNGmzo0-SlBsN-007tA
{'challengeId': '0279b094-07bf-425e-9657-73be34fa2ee9', 'challengeMetadata': '{"verificationToken":"wC0TNGmzo0-SlBsN-007tA","rememberDevice":false,"challengeId":"wC0TNGmzo0-SlBsN-007tA2","actionType":"GenericWithRecoveryCodes"}', 'challengeType': 'twostepverification'}
{'statusCode': 400, 'statusText': 'Bad Request', 'errors': [{'code': 1, 'message': 'an internal error occurred'}]}

Never mid I fixed the error if anyone has a similar error in the future here is my fix:

data = {
    "challengeId": rblx_challenge_id,
    "challengeType": "twostepverification",
    "challengeMetadata": json.dumps({
        "verificationToken": verification_token,
        "rememberDevice": False,
        "challengeId": actual_challenge_id,
        "actionType": "THE TYPE"
    })
}

response = requests.post("https://apis.roblox.com/challenge/v1/continue", headers=headers, json=data)
print(response.json())

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.