From c7b71d87a70735b69d823a92179be9eda2c13f10 Mon Sep 17 00:00:00 2001 From: Ammar Askar Date: Sun, 22 Mar 2015 03:44:45 +0500 Subject: [PATCH] Update arbitrary request example to follow better practices --- docs/authentication.rst | 11 ++++++----- network/connection.py | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/authentication.rst b/docs/authentication.rst index 22c0393..35373c9 100644 --- a/docs/authentication.rst +++ b/docs/authentication.rst @@ -48,10 +48,11 @@ You may make any arbitary request to the Yggdrasil service with --------------- An example of making an arbitary request can be seen here:: - url = "https://sessionserver.mojang.com/session/minecraft/join" - server_id = encryption.generate_verification_hash(packet.server_id, secret, packet.public_key) + url = authentication.BASE_URL + "session/minecraft/join" + server_id = encryption.generate_verification_hash(packet.server_id, secret, packet.public_key) + payload = {'accessToken': self.connection.login_response.access_token, + 'selectedProfile': self.connection.login_response.profile_id, + 'serverId': server_id} - response = authentication.make_request(url, {'accessToken': self.connection.login_response.access_token, - 'selectedProfile': self.connection.login_response.profile_id, - 'serverId': server_id}) + authentication.make_request(url, payload) diff --git a/network/connection.py b/network/connection.py index d8a37b9..bb10769 100644 --- a/network/connection.py +++ b/network/connection.py @@ -250,12 +250,13 @@ class LoginReactor(PacketReactor): # A server id of '-' means the server is in offline mode if packet.server_id != '-': - url = "https://sessionserver.mojang.com/session/minecraft/join" + url = authentication.BASE_URL + "session/minecraft/join" server_id = encryption.generate_verification_hash(packet.server_id, secret, packet.public_key) + payload = {'accessToken': self.connection.login_response.access_token, + 'selectedProfile': self.connection.login_response.profile_id, + 'serverId': server_id} - authentication.make_request(url, {'accessToken': self.connection.login_response.access_token, - 'selectedProfile': self.connection.login_response.profile_id, - 'serverId': server_id}) + authentication.make_request(url, payload) encryption_response = EncryptionResponsePacket() encryption_response.shared_secret = encrypted_secret