Example #1
0
        internal static RestTokenInfo Create(Model model, string token)
        {
            var entity = new RestTokenInfo(token);

            entity.Update(model);
            return(entity);
        }
Example #2
0
        // 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);
        }
Example #3
0
 public static bool TryGetToken(BaseRestClient client, ulong id, out RestTokenInfo info)
 {
     if (client.Tokens.TryGetValue(id, out info))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #4
0
        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);
        }