internal static RestTokenInfo Create(Model model, string token) { var entity = new RestTokenInfo(token); entity.Update(model); return(entity); }
// Tokens public static async Task <RestTokenInfo> GetTokenInfoAsync(BaseTwitchClient client, RequestOptions options = null) { var model = await client.ApiClient.ValidateTokenAsync(options).ConfigureAwait(false); if (model.Token != null) { return(RestTokenInfo.Create(client.ApiClient.AuthToken, model.Token)); } return(null); }
public static bool TryGetToken(BaseRestClient client, ulong id, out RestTokenInfo info) { if (client.Tokens.TryGetValue(id, out info)) { return(true); } else { return(false); } }
public static async Task <RestTokenInfo> AuthorizeAsync(BaseRestClient client, string token) { await client.Logger.InfoAsync("Rest", "Logging in...").ConfigureAwait(false); var model = await client.RestClient.AuthorizeAsync(token); var entity = RestTokenInfo.Create(model, token); await client.Logger.InfoAsync("Rest", "Login success!").ConfigureAwait(false); return(entity); }