Legacy Mojang Account
This api has been deprecated since Mojang closed their legacy login api.
Use Microsoft Xbox Account instead.
For legacy mojang account,
MLogin
class provides methods to communicate with the Mojang auth server.MLoginResponse
class represents login result. Methods inMLogin
class return this object.MSession
class represents player's session data, containingUsername
,UUID
, andAccessToken
.
Note: this document will help you to understand basic process of minecraft login.
Mojang Login
PremiumLogin() in CmlLibCoreSample
MLogin
Provides methods to communicate with the Mojang auth server and cache game session.
All methods return MLoginResult. You can get the result of login and result session from MLoginResponse
.
This class fully implments Yggdrasil authentication scheme.
Constructor
public MLogin()
Initialize object with default login cache file path. Default path : Path.Combine(MinecraftPath.GetOSDefaultPath(), "logintoken.json")
public MLogin(string sessionCacheFilePath)
Initializes object and sets SessionCacheFilePath
.
Properties
SessionCacheFilePath
Type: string
SessionCacheFilePath
SaveSession
Save session data to SessionCacheFilePath
if this true. Default value is true.
Methods
public MSession ReadSessionCache()
Returns session from cache file.
public MLoginResponse Authenticate(string id, string pw)
Login with Mojang email and password, with cached clientToken.
public MLoginResponse Authenticate(string id, string pw, string clientToken)
Login with Mojang email and password.
public MLoginResponse TryAutoLogin()
Checks validation of cached session and refresh session if it is not valid session.
public MLoginResponse TryAutoLogin(MSession session)
Checks validation of the specified session and refresh session if it is not valid session.
public MLoginResponse Refresh()
Refresh session using cached session.
public MLoginResponse Refresh(MSession session)
Refresh the specified session.
public MLoginResponse Validate()
Validate session with cached session.
public MLoginResponse Validate(MSession session)
Validate the specified session.
public void DeleteTokenFile()
Delete cached session file. This is the easiest way to logout.
public bool Invalidate()
Logout with cached session file.
public bool Invalidate(MSession session)
Logout the specified session.
public bool Signout(string id, string pw)
Logout using Mojang email and password.
MLoginResponse
Indicates the login response.
Properties
IsSuccess
Type: bool
Returns true if Result
is MLoginResult.Success
.
Result
Type: MLoginResponse
Login Result. If this property is not MLoginResult.Success
, then Session
will be null.
Session
Type: Login and Sessions
Result session.
ErrorMessage
Type: string
Error message. It is set when the Result
property is not MLoginResult.Success
. This property can be empty or a null string when the login result is not successful.
MLoginResult
Indicates the login result.
Fields
Success
Login successful.
BadRequest
WrongAccount
NeedLogin
UnknownError
NoProfile
User doesn't purchase minecraft.
Last updated