pyCraft/docs/authentication.rst

53 lines
1.5 KiB
ReStructuredText
Raw Permalink Normal View History

2015-03-21 23:08:44 +01:00
Authentication
==============
2016-12-19 11:26:12 +01:00
.. currentmodule:: minecraft.authentication
2015-03-21 23:08:44 +01:00
.. _Yggdrasil: http://wiki.vg/Authentication
.. _LoginResponse: http://wiki.vg/Authentication#Authenticate
The authentication module contains functions and classes to facilitate
2016-12-19 11:26:12 +01:00
interfacing with Mojang's Yggdrasil_ authentication service.
2015-03-21 23:08:44 +01:00
Logging In
~~~~~~~~~~~~~~~~~~~~
The most common use for this module in the context of a client will be to
2016-12-19 11:26:12 +01:00
log in to a Minecraft account. The first step to doing this is creating
an instance of the AuthenticationToken class after which you may use the
authenticate method with the user's username and password in order to make the AuthenticationToken valid.
2015-03-21 23:08:44 +01:00
2016-12-19 11:26:12 +01:00
.. autoclass:: AuthenticationToken
:members: authenticate
2015-03-21 23:08:44 +01:00
2016-12-19 11:26:12 +01:00
Upon success, the function returns True, on failure a YggdrasilError
is raised. This happens, for example if an incorrect username/password
is provided or the web request failed.
2015-03-21 23:08:44 +01:00
.. autoexception:: YggdrasilError
:members:
2018-10-08 11:25:58 +02:00
Arbitrary Requests
2015-03-21 23:08:44 +01:00
~~~~~~~~~~~~~~~~~~~~
2018-10-08 11:25:58 +02:00
You may make any arbitrary request to the Yggdrasil service with the _make_request
2016-12-19 11:26:12 +01:00
method passing in the AUTH_SERVER as the server parameter.
2015-03-21 23:08:44 +01:00
2016-12-19 11:26:12 +01:00
.. automodule:: minecraft.authentication
:members: AUTH_SERVER
2015-03-21 23:08:44 +01:00
2016-12-19 11:26:12 +01:00
.. autofunction:: _make_request
2015-03-21 23:08:44 +01:00
---------------
Example Usage
---------------
2018-10-08 11:25:58 +02:00
An example of making an arbitrary request can be seen here::
2015-03-21 23:08:44 +01:00
2016-12-19 11:26:12 +01:00
payload = {'username': username,
'password': password}
2015-03-21 23:08:44 +01:00
2016-12-19 11:26:12 +01:00
authentication._make_request(authentication.AUTH_SERVER, "signout", payload)
2015-03-21 23:08:44 +01:00