protected async Task <TokenModel> AuthorizeToSteem(CancellationToken token = default(CancellationToken)) { var login = ConfigurationManager.AppSettings["SteemLogin"]; var password = ConfigurationManager.AppSettings["SteemPostingWif"]; var keys = new List <byte[]> { Base58.DecodePrivateWif(password) }; var op = new Ditch.Steem.Operations.FollowOperation(login, "steepshot", Ditch.Steem.Models.FollowType.Blog, login); var properties = new Ditch.Steem.Models.DynamicGlobalPropertyObject { HeadBlockId = "0000000000000000000000000000000000000000", Time = DateTime.Now, HeadBlockNumber = 0 }; var operationManager = new Ditch.Steem.OperationManager(null); var tr = await operationManager.CreateTransactionAsync(properties, keys, op, token).ConfigureAwait(false); var trx = JsonConvert.SerializeObject(tr, operationManager.CondenserJsonSerializerSettings); var authModel = new AuthModel { Args = trx, AuthType = AuthType.Steem }; HttpContent content = new StringContent(JsonConvert.SerializeObject(authModel), Encoding.UTF8, "application/json"); var httpClient = new HttpClient(); var response = await httpClient.PostAsync(AuthApiUrl, content, token).ConfigureAwait(false); var opt = await CreateResultAsync <TokenModel>(response, token).ConfigureAwait(false); Assert.IsTrue(opt.IsSuccess, opt.Exception.Message); Assert.IsTrue(opt.Result.Login.Equals(login)); Assert.IsTrue(opt.Result.Type == AuthType.Steem); return(opt.Result); }
public ApiProvider(IConfiguration configuration, HttpManager httpManager, WebSocketManager webSocketManager) { _steem = new Ditch.Steem.OperationManager(httpManager); _golos = new Ditch.Golos.OperationManager(webSocketManager); _configuration = configuration; }