public AuthenticationInfo Do() { var client = new YggdrasilClient(AuthServer, ClientToken); if (client.Authenticate(Email, Password, TwitchEnabled)) { return new AuthenticationInfo { AccessToken = client.AccessToken, UserType = client.AccountType, DisplayName = client.DisplayName, Properties = client.Properties, UUID = client.UUID }; } return new AuthenticationInfo { Error = "验证错误" }; }
public Task<AuthenticationInfo> DoAsync(CancellationToken token) { var client = new YggdrasilClient(AuthServer, ClientToken); return client.AuthenticateAsync(Email, Password, Token, TwitchEnabled, token).ContinueWith(task => { if ((task.Exception == null) && (task.Result)) { return new AuthenticationInfo { AccessToken = client.AccessToken, UserType = client.AccountType, DisplayName = client.DisplayName, Properties = client.Properties, UUID = client.UUID }; } return new AuthenticationInfo { Error = "验证错误" }; }, token); }