public async Task <object> GetAsync([FromQuery] BToken token) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else { Exchange response = await "https://bittrex.com/api/v1.1/public/getmarkets" .GetJsonAsync <Exchange>(); if (!string.IsNullOrEmpty(token.curr)) { List <Result> results = new List <Result>(); foreach (var r in response.Result) { if (r.MarketCurrency == token.curr) { results.Add(r); } } if (results.Count() == 0) { return("Entered Token is not valid, Please correct and retry"); } return(results); } return(response); } }
private static bool AuthenticateUser(string token) { BToken bToken = new BToken(); if (!bToken.Validate(token)) { return(false); } var username = bToken.GetUsername(token); var identity = new GenericIdentity(username); SetPrincipal(new GenericPrincipal(identity, null)); return(true); }
private static void OnApplicationEndRequest(object sender, EventArgs e) { var response = HttpContext.Current.Response; if (response.StatusCode == 401) { //response.Headers.Add("WWW-Authenticate", string.Format("Basic realm=\"{0}\"", Realm)); } else { var request = HttpContext.Current.Request; var authHeader = request.Headers["Authorization"]; if (authHeader != null) { var authHeaderVal = AuthenticationHeaderValue.Parse(authHeader); if (authHeaderVal.Scheme.Equals("basic", StringComparison.OrdinalIgnoreCase) && authHeaderVal.Parameter != null) { BToken bToken = new BToken(); var newToken = bToken.Renew(authHeaderVal.Parameter); response.Headers.Add("Authorization", newToken); } } } }
public override async Task <ResponseBase> SetObservableToken(SignUpSender signUpSender, BToken token) { var config = await Context.GetConfiguration <ConfigWhatsApp>(this.Provider.ServiceName, signUpSender.UserId); config.Token = token.Token; var pws = WhatsAppApi.Register.WhatsRegisterV2.RegisterCode(config.Phone, config.Token); //config.TempPwsSms = config.Token; config.Token = pws;//curent var result = await this.Context.SetConfiguration(this.Provider.ServiceName, signUpSender.UserId, config); return(result); }
public override async Task <ResponseBase> SetObservableToken(SignUpSender signUpSender, BToken token) { var config = await Context.GetConfiguration <ConfigHttp>(this.Provider.ServiceName, signUpSender.UserId); config.Token = token.Token; var result = await this.Context.SetConfiguration(this.Provider.ServiceName, signUpSender.UserId, config); return(result); }
public override async Task <ResponseBase> SetObservableToken(SignUpSender signUpSender, BToken token) { ConfigTelegram configTelegram = await Context.GetConfiguration <ConfigTelegram>(Provider.ServiceName, signUpSender.UserName); var store = new BaladorSessionStore(this.Context, configTelegram, this.Provider, signUpSender); var client = new TelegramClient(configTelegram.Api, configTelegram.Api_Hash, store); var user = await client.MakeAuthAsync(configTelegram.Phone, configTelegram.CodeRequest, token.Token); configTelegram.Token = token.Token; var result = await this.Context.SetConfiguration(this.Provider.ServiceName, signUpSender.UserName, configTelegram); return(result); }
public override async Task <ResponseBase> SetObservableToken(SignUpSender signUpSender, BToken token) { var config = await Context.GetConfiguration <ConfigHttpLite>(this.Provider.ServiceName, signUpSender.UserId); if (config == null) { config = new ConfigHttpLite { Token = token.Token, UserId = signUpSender.UserId }; } else { config.Token = token.Token; } var result = await this.Context.SetConfiguration(this.Provider.ServiceName, signUpSender.UserId, config); return(result); }