public GitHubApiHelper(BlavenBlogSetting setting) { this.setting = setting; var authenticator = new HttpBasicAuthenticator(setting.Username, setting.Password); this.restClient = new RestClient(ApiBaseUrl) { UserAgent = "Blaven", Authenticator = authenticator }; this.contentsApiPath = this.GetContentsApiPath(); }
internal RestAPIRequest(string username, string apikey, string baseUrl, string apiVersion) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; _auth = new HttpBasicAuthenticator(username, apikey); var version = Assembly.GetExecutingAssembly().GetName().Version; _userAgent = "DataSift/v" + apiVersion + " Dotnet/v" + version.ToString(); _baseUrl = baseUrl; _apiVersion = apiVersion; }
public EncentivizeRestClient(EncentivizeSettings settings) : base(settings.BaseUrl) { Settings = settings; if (Settings.AuthenticaionTypeToUse == AuthenticaionType.Basic) { Authenticator = new HttpBasicAuthenticator(Settings.Username, Settings.Password); } else if (Settings.AuthenticaionTypeToUse == AuthenticaionType.Neuron) { Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(Settings.BearerToken, "bearer"); } AddHandler("application/json", new DynamicJsonDeserializer()); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null || value.ToString() == "") return null; RestClient client = new RestClient(); var request = new RestRequest(value.ToString(), Method.GET); try {//workaround because I use a class for this XD string exeConfigPath = this.GetType().Assembly.Location; string dir = Path.GetDirectoryName(exeConfigPath); string[] files = System.IO.Directory.GetFiles(dir, "*.config"); string mainassembly = ""; foreach (var f in files) { if (!f.Contains(this.GetType().Assembly.FullName) && !f.Contains("vshost")) { mainassembly = f.Substring(0, f.Length - 7); break; } } string username = MySettings.Get("username"); string password = DataProtector.DecryptData(MySettings.Get("password")); if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password)) return null; HttpBasicAuthenticator user = new HttpBasicAuthenticator(username, password); client.Authenticator = user; } catch (Exception ex1) { MessageBox.Show("exception: " + ex1); } // var response = client.Execute(request); return LoadImage(response.RawBytes); }
public void onClick(object o, EventArgs e) { FunAPI api = FunAPI.Instance; var authenticator = new HttpBasicAuthenticator (usernameTextField.Text, passwordTextField.Text); Console.WriteLine("Authenticating: "+ authenticator.ToString()); api.Login (authenticator, response => { if (response.Error != null) { Console.WriteLine("Authentication Failed: "+ response.Error.Message); } else { Console.WriteLine("Authentication successfull. Welcome "+response.Data.DisplayName); } }); }
public VersionOneRestClient(string baseUrl, string userName, string password) : base(baseUrl) { Require.Argument("baseUrl", baseUrl); if (string.IsNullOrWhiteSpace(userName)) { throw new ArgumentNullException("userName"); } if (string.IsNullOrWhiteSpace(password)) { throw new ArgumentNullException("password"); } Authenticator = new HttpBasicAuthenticator(userName, password); AddHandler("text/xml", new AssetDeserializer()); }
private static RestClient GetNewGitHubClient(string gitHubUsername, string gitHubPassword) { var client = new RestClient("https://api.github.com"); IAuthenticator auth = new HttpBasicAuthenticator(gitHubUsername, gitHubPassword); client.Authenticator = auth; return client; }
internal TournamentRepository(string baseUrl, HttpBasicAuthenticator authenticator) : base(baseUrl, authenticator) { EndPointName = "tournaments"; }
public ChallongeLib(HttpBasicAuthenticator authenticator) { Tournaments = new TournamentRepository("https://api.challonge.com/v1/", authenticator); }
internal Authenticator(string site, string user, string password) { _authenticator = new HttpBasicAuthenticator(site + "\\" + user, password); }
internal BaseRepository(string baseUrl, HttpBasicAuthenticator authenticator) { Rest = new RestConsumer(baseUrl, authenticator); FormatExtension = ".json"; }
protected void LoginHandler(object sender, EventArgs e) { FunAPI api = FunAPI.Instance; var authenticator = new HttpBasicAuthenticator(this.UsernameTextField.Text, this.PasswordTextField.Text); BTProgressHUD.Show("Authenticating..."); api.Login(authenticator, response => { if (response.Error != null) { BTProgressHUD.ShowErrorWithStatus("Error: " + response.Error.Message, timeoutMs: 3000); } else { BTProgressHUD.ShowSuccessWithStatus("Authenticated!!! Welcome " + response.Data.DisplayName); } }); }
public void SetUp() { IAuthenticator authenticator = new HttpBasicAuthenticator(c_jiraUsername, c_jiraPassword); _restClient = new JiraRestClient (c_jiraUrl, authenticator); _service = new JiraProjectVersionService (_restClient); _versionFinder = new JiraProjectVersionFinder (_restClient); _issueService = new JiraIssueService (_restClient); }