xboxlive.com endpoint returns 400

ward franssen 0 Reputation points
2024-09-22T23:33:58.59+00:00

Why isn't this working for me the first endpoint is returning code 400 with no text/json.

def authenticate_xbox(access_token):
    headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
    }
    body = {
        'Properties': {
            'AuthMethod': 'RPS',
            'SiteName': 'user.auth.xboxlive.com',
            'RpsTicket': f'd={access_token}'
        },
        'RelyingParty': 'http://auth.xboxlive.com',
        'TokenType': 'JWT'
    }

    response = requests.post('https://user.auth.xboxlive.com/user/authenticate', json=body, headers=headers)
    if response.status_code != 200:
        print(response.status_code)
        raise Exception(f'Failed to authenticate with Xbox API: {response.text}')
    return response.json()['Token']

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,143 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.