Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I can't get the url using json python

I’m trying to get the url of the minecraft skin through the api using python programming but I can’t get the url, let’s see if someone could

This is the code I’m currently using…

    import json
    import requests
    import base64
    
    
    
    
response = requests.get(f"https://sessionserver.mojang.com/session/minecraft/profile/11f1cc006cc84499a174bc9b7fa1982a")
    id = response.json()["properties"][0]["value"]
    
    ####
    msg = f"{id}"
    msg_bytes = msg.encode('ascii')
    base64_bytes = base64.b64decode(msg_bytes)
    base64_msg = base64_bytes.decode('ascii')
    
    
    
    
    print(base64_msg)

Thank you very much in advance!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You will have to convert the string to json first.

import requests
import base64
import json

response = requests.get(
    f"https://sessionserver.mojang.com/session/minecraft/profile/11f1cc006cc84499a174bc9b7fa1982a"
)
msg = response.json()["properties"][0]["value"]


base64_bytes = base64.b64decode(msg)

print(json.loads(base64_bytes)["textures"]["SKIN"]["url"])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading