0

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":[]}
9
  • Try using 'Authorization': 'Bearer ' + token Commented May 24, 2021 at 17:36
  • 1
    Please, add output of r.text to a post. It may be caused by invalid token Commented May 24, 2021 at 17:54
  • 1
    So, what's the problem with an application? You're getting a response. Commented May 24, 2021 at 18:04
  • 1
    By specification of HTTP status codes, status code 200 is returned when the application processed the request successfully. You can check whether user exists or not by checking length of profiles array. Something like userWasFound = len(r.json()['profiles']) != 0 Commented May 24, 2021 at 18:12
  • 1
    Yep, this looks correct for me Commented May 24, 2021 at 18:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.