I'm trying to make an username checker for Ubisoft using Python's requests. When I run my code I always get a status code 200, which should indicate that the username is available, even when the username is taken. I checked the request link and it says:
{"moreInfo":"","errorCode":3,"httpCode":401,"errorContext":"Shipyard.Profiles.Services","message":"The Authorization header is missing","environment":"prod","additionalDetails":{},"transactionTime":"2021-05-24T17:27:50.9065561Z","transactionId":"5d4edaf2-8e8f-4e3f-9736-fce6aea82e32"}
However, I added 'Authorization':token to my code with token being an input you get from the authority website after logging in.
My code:
import requests
import json
def check():
username = input("What name to check? :")
print(" ")
token = input("Enter token: ")
r = requests.get("https://public-ubiservices.ubi.com/v2/profiles?nameOnPlatform=" + username + "&platformType=uplay", headers = {
'Method':'GET',
'Authority':'public-ubiservices.ubi.com',
'Ubi-AppId':'c5393f10-7ac7-4b4f-90fa-21f8f3451a04',
'Authorization': token,
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36',
'Ubi-RequestedPlatformType':'uplay',
})
print(r.status_code)
print(r.text)
print("Press ENTER to start checking")
input("")
check()
Edit: Added r.text
r.text gives this as output for what should be a taken username (username = test)
200
{"profiles":[{"profileId":"21067093-822e-497d-ae8a-5d171573f6c8","userId":"21067093-822e-497d-ae8a-5d171573f6c8","platformType":"uplay","idOnPlatform":"21067093-822E-497D-AE8A-5D171573F6C8","nameOnPlatform":"test"}]}
and r.text gives this as output for a what should be available username (username = test815581m)
200
{"profiles":[]}
'Authorization': 'Bearer ' + tokenr.textto a post. It may be caused by invalid tokenprofilesarray. Something likeuserWasFound = len(r.json()['profiles']) != 0