“需要质询才能授权请求”错误

问题描述 投票:0回答:1

我正在制作一个 Roblox Group 机器人,并且我正在使用 Roblox Group V2/1 API,但随后:

“需要挑战才能授权”

我的请求在执行时收到响应,我不知道从哪里获取验证码:Id、Token、Provider 和challengeId,有人可以帮我尝试解决我的代码吗? 我以前从未尝试过创建机器人,而且我仍在学习

这是代码:

import requests
import os

# Replace with your group ID
GROUP_ID = 34166526
ROBLOSECURITY_COOKIE = "nah"

def get_csrf_token():
    auth_url = "https://auth.roblox.com/v1/logout"
    xsrf_request = requests.post(auth_url, cookies={".ROBLOSECURITY": ROBLOSECURITY_COOKIE})

    if xsrf_request.status_code == 401:
        print("Invalid ROBLOSECURITY cookie. Exiting.")
        exit()
    else:
        print("Validation success.")
        return xsrf_request.headers["x-csrf-token"]

def is_user_in_group():
    try:
        csrf_token = get_csrf_token()
        response = requests.get(f"https://groups.roblox.com/v1/groups/{GROUP_ID}/membership", params={
            "groupId": GROUP_ID,
            "includeNotificationPreferences": True
        }, headers={
            "Cookie": f".ROBLOSECURITY={ROBLOSECURITY_COOKIE}",
            "X-CSRF-TOKEN": csrf_token
        })
        if response.status_code == 200:
            print("This works!", response.text)
        else:
            print("This DON'T work!", response.text)

        response_json = response.json()
        return GROUP_ID in response_json
    except Exception as e:
        print(f"Error checking group membership: {e}")
        return False

def join_group():
    try:
        csrf_token = get_csrf_token()
        response = requests.post(f"https://groups.roblox.com/v1/groups/{GROUP_ID}/users", json={
            "captchaId": "78417cb70582c6e31.3755809701",
            "captchaToken": "78417cb70582c6e31.3755809701",
            "captchaProvider": "string",
            "challengeId": "78417cb70582c6e31.3755809701"
        }, headers={
            "Cookie": f".ROBLOSECURITY={ROBLOSECURITY_COOKIE}",
            "X-CSRF-TOKEN": csrf_token,
            "Content-Type": "application/json"  
        })

        if response.status_code == 200:
            print("Joined the group successfully!")
        else:
            print(f"Error joining the group: {response.text}")
    except Exception as e:
        print(f"Error joining the group: {e}")

def post_message_on_wall():
    try:
        csrf_token = get_csrf_token()
        response = requests.post(f"https://groups.roblox.com/v2/groups/{GROUP_ID}/wall/posts", json={
            "body": "Hello! I'm a Roblox Bot! Made by Bacon!",  
            "captchaId": "",
            "captchaToken": "78417cb70582c6e31.3755809701",
            "captchaProvider": "arkose-labs",
            "challengeId": ""
        }, headers={
            "Cookie": f".ROBLOSECURITY={ROBLOSECURITY_COOKIE}",
            "Content-Type": "application/json",
            "X-CSRF-TOKEN": csrf_token,
        })
        if response.status_code == 200:
            print("Posted message on the group wall successfully!")
        else:
            print(f"Error posting message on the group wall: {response.text}")
    except Exception as e:
        print(f"Error posting message on the group wall: {e}")

if __name__ == "__main__":
    if not is_user_in_group():
        join_group()
    post_message_on_wall()
python windows python-requests roblox
1个回答
0
投票

这是因为要加入群组,您可能需要完成验证码,而这在自动化系统上无法轻松(且不违反 TOS)完成。

您应该手动将机器人加入群组。

© www.soinside.com 2019 - 2024. All rights reserved.