TypeError: post_request() missing 2 required positional arguments: 'token' and 'uuid'

Question:

So as information I tried to make a script to check if the SessionID is valid in Minecraft and then send it to a webhook.

File "c:UsersPCDesktopRandomShitdhook.py", line 43, in <module>
    isValid = post_request()
TypeError: post_request() missing 2 required positional arguments: 'token' and 'uuid'

So this is the code but for some reason it just doesn’t work, I’m pretty new to python and coding in general and need help with this.

from cgitb import text
from dhooks import Webhook, Embed
import requests
import json

hook = Webhook('https://discord.com/api/webhooks/1000036496658669619/OChDQ2Whz86jlIrXDelDUUybjQ0DPXkEWRB9QRInBJb18Ww4W-NPo_ZM_fVwnHQ88gh0')
token = "Token Here"
uuid = "UUID Here"

def send(token, uuid):
#embed json
  embed = Embed(
    title= "Token Validator",
    color=0x68228B,
    timestamp='now'  # sets the timestamp to current time
    )



  embed.add_field(name='UUID', value=uuid, inline='false')
  embed.add_field(name='Token', value=token, inline='false')


  hook.send(embed=embed)

def post_request(token, uuid):
    url = "https://sessionserver.mojang.com/session/minecraft/join"
    payload = {
        "accessToken": token,
        "selectedProfile": uuid,
        "serverId": uuid
    }
    headers = {
        'Content-Type': "application/json"
    }
    response = requests.post(url, data=json.dumps(payload), headers=headers)
    if response.status_code == 204:
        return True
    else:
        print(response.text)
        return False

isValid = post_request()
if isValid:
    print("token is valid")
    send(token, uuid)
else:
    print("token is invalid")

All the help I can get is appreciated.

Asked By: Young Prodigy

||

Answers:

you forgot to pass token, uuid into the request function

from cgitb import text
from dhooks import Webhook, Embed
import requests
import json

hook = Webhook('https://discord.com/api/webhooks/1000036496658669619/OChDQ2Whz86jlIrXDelDUUybjQ0DPXkEWRB9QRInBJb18Ww4W-NPo_ZM_fVwnHQ88gh0')
token = "Token Here"
uuid = "UUID Here"

def send(token, uuid):
#embed json
  embed = Embed(
    title= "Token Validator",
    color=0x68228B,
    timestamp='now'  # sets the timestamp to current time
    )



  embed.add_field(name='UUID', value=uuid, inline='false')
  embed.add_field(name='Token', value=token, inline='false')


  hook.send(embed=embed)

def post_request(token, uuid):
    url = "https://sessionserver.mojang.com/session/minecraft/join"
    payload = {
        "accessToken": token,
        "selectedProfile": uuid,
        "serverId": uuid
    }
    headers = {
        'Content-Type': "application/json"
    }
    response = requests.post(url, data=json.dumps(payload), headers=headers)
    if response.status_code == 204:
        return True
    else:
        print(response.text)
        return False

isValid = post_request(token, uuid) # add this here
if isValid:
    print("token is valid")
    send(token, uuid)
else:
    print("token is invalid")
Answered By: Dean Van Greunen
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.