mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
validates token successully
This commit is contained in:
parent
1a41c42ba9
commit
8c065320c2
1 changed files with 33 additions and 0 deletions
|
|
@ -211,6 +211,39 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
}
|
||||
|
||||
public enum ValidationResult { Validated, RefreshRequired, Error };
|
||||
|
||||
/// <summary>
|
||||
/// Validates whether accessToken must be refreshed
|
||||
/// </summary>
|
||||
/// <param name="accesstoken">Will contain the cached access token previously returned by Minecraft.net</param>
|
||||
/// <returns>Returns the status of the token (Valid, Invalid, etc.)</returns>
|
||||
///
|
||||
public static ValidationResult GetTokenValidation(string accesstoken)
|
||||
{
|
||||
try
|
||||
{
|
||||
string result = "";
|
||||
string json_request = "{\"accessToken\": \"" + jsonEncode(accesstoken) + "\" }";
|
||||
int code = doHTTPSPost("authserver.mojang.com", "/validate", json_request, ref result);
|
||||
if (code == 204)
|
||||
{
|
||||
return ValidationResult.Validated;
|
||||
}
|
||||
else if (code == 403)
|
||||
{
|
||||
return ValidationResult.RefreshRequired;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ValidationResult.Error;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return ValidationResult.Error;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Check session using Mojang's Yggdrasil authentication scheme. Allows to join an online-mode server
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue