CmlLib
한국어 (v3)
한국어 (v3)
  • 🧊CmlLib Projects
  • [AD] 커스텀 런처 주문제작
  • 🚀CmlLib.Core
    • 홈
    • 시작하기
      • CMLauncher
      • 게임 경로 설정
      • 실행 옵션 설정
      • 이벤트 처리
    • 로그인과 세션
      • 마이크로소프트 엑스박스 계정
      • 예전 모장 계정
      • 오프라인 계정
    • 고급 기능
      • VersionLoader
      • Version
      • FileChecker
      • Downloader
    • 모드 로더 인스톨러
      • Forge Installer
      • Fabric Installer
      • LiteLoader Installer
    • 유틸리티
      • Minecraft Changelogs
    • 자료
      • 자주 묻는 질문
      • 알려진 문제
      • 예시 런처
      • 라이센스
  • 🔓Auth.Microsoft
    • 홈
    • CmlLib.Core.Auth.Microsoft
      • JELoginHandler
      • JELoginHandlerBuilder
      • JEAuthenticator
    • XboxAuthNet.Game
      • OAuth
      • XboxAuth
      • XboxAuthException
      • AccountManager
      • Accounts
    • XboxAuthNet.Game.Msal
      • ClientID
      • MsalClientHelper
      • OAuth
    • CmlLib.Core.Bedrock.Auth
    • 자료
  • 🌐MojangAPI
    • 홈
    • Mojang API
    • SecurityQuestion
  • ⚒️Installer.Forge
    • 홈
    • 지원되는 버전
    • 시작하기
    • MForge
    • ForgeVersionLoader
Powered by GitBook
On this page
  • Mojang Login
  • MLogin
  • Constructor
  • Properties
  • Methods
  • MLoginResponse
  • Properties
  • MLoginResult
  • Fields
Edit on GitHub
  1. CmlLib.Core
  2. 로그인과 세션

예전 모장 계정

Previous마이크로소프트 엑스박스 계정Next오프라인 계정

Last updated 1 year ago

이 API 는 사용 불가능합니다! 모장에서 더 이상 예전 계정으로 로그인하지 못하게 API 를 막았습니다.

마이크로소프트 엑스박스 계정을 사용하세요.

For legacy mojang account,

  • MLogin class provides methods to communicate with the Mojang auth server.

  • MLoginResponse class represents login result. Methods in MLogin class return this object.

  • MSession class represents player's session data, containing Username, UUID, and AccessToken.

Note: will help you to understand basic process of minecraft login.

Mojang Login

The basic login process is:

var login = new MLogin();

// TryAutoLogin() reads the login cache file and check validation.
// If the cached session is invalid, it refreshes the session automatically.
// Refreshing the session doesn't always succeed, so you have to handle this.
Console.WriteLine("Attempting to automatically log in.");
var response = login.TryAutoLogin();

if (!response.IsSuccess) // if cached session is invalid and failed to refresh token
{
    Console.WriteLine("Auto login failed: {0}", response.Result.ToString());

    Console.WriteLine("Input your Mojang email: ");
    var email = Console.ReadLine();
    Console.WriteLine("Input your Mojang password: ");
    var pw = Console.ReadLine();

    response = login.Authenticate(email, pw);

    if (!response.IsSuccess)
    {
        // session.Message contains a detailed error message. It can be null or an empty string.
        Console.WriteLine("failed to login. {0} : {1}", response.Result.ToString(), response.ErrorMessage);
        Console.ReadLine();
        Environment.Exit(0);
    }
}

// The result Session
MSession session = response.Session;

// var launchOption = new MLaunchOption()
// {
//      Session = session,
//      // launch options
// };

MLogin

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: 로그인과 세션

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.

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
this document
PremiumLogin() in CmlLibCoreSample