public Dictionary <string, string> RequestUserProfile() { string profileUrl = string.Format("https://apis.live.net/v5.0/me?access_token={0}", _client.Token); var header = new NameValueCollection(); header.Add("Accept-Language", "en_US"); string result = RestfullRequest.Request(profileUrl, "GET", null, header, null, _client.Proxy); //_client.ProfileJsonString = result; WindowsLiveClient.UserProfile data = JsonConvert.DeserializeAnonymousType(result, new WindowsLiveClient.UserProfile()); var dictionary = new Dictionary <string, string>(); dictionary.Add("source", "WindowsLive"); dictionary.Add("id", data.Id); dictionary.Add("name", data.Name); dictionary.Add("first_name", data.First_name); dictionary.Add("last_name", data.Last_name); dictionary.Add("link", data.Link); dictionary.Add("gender", data.Gender); dictionary.Add("email", data.Emails.Preferred); return(dictionary); }
public Dictionary <string, string> RequestUserProfile() { string profileUrl = string.Format(OAUTH_API_URL + "/v1/identity/openidconnect/userinfo/?schema=openid"); NameValueCollection header = new NameValueCollection(); header.Add("Accept-Language", "en_US"); header.Add("Authorization", "Bearer " + _client.Token); string result = RestfullRequest.Request(profileUrl, "POST", "application/json", header, null, _client.Proxy); _client.ProfileJsonString = result; PayPalClient.UserProfile data = JsonConvert.DeserializeAnonymousType(result, new PayPalClient.UserProfile()); Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("source", "PayPal"); dictionary.Add("email", data.Email); dictionary.Add("verified_email", data.Verified_email); dictionary.Add("name", data.Name); dictionary.Add("given_name", data.Given_name); dictionary.Add("family_name", data.Family_name); dictionary.Add("link", data.User_id); dictionary.Add("picture", data.Picture); dictionary.Add("gender", data.Gender); return(dictionary); }
public Dictionary <string, string> RequestUserProfile() { string profileUrl = string.Format("https://www.googleapis.com/oauth2/v1/userinfo?access_token={0}", _client.Token); NameValueCollection header = new NameValueCollection(); header.Add("Accept-Language", "en_US"); string result = RestfullRequest.Request(profileUrl, "GET", "application/x-www-form-urlencoded", header, null, _client.Proxy); _client.ProfileJsonString = result; GoogleClinet.UserProfile data = JsonConvert.DeserializeAnonymousType(result, new GoogleClinet.UserProfile()); Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("source", "Google"); dictionary.Add("id", data.Id); dictionary.Add("email", data.Email); dictionary.Add("verified_email", data.Verified_email); dictionary.Add("name", data.Name); dictionary.Add("given_name", data.Given_name); dictionary.Add("family_name", data.Family_name); dictionary.Add("link", data.Link); dictionary.Add("picture", data.Picture); dictionary.Add("gender", data.Gender); return(dictionary); }
protected string HttpPost(string urlToPost, string postData) { var result = RestfullRequest.Request(urlToPost, "POST", "application/x-www-form-urlencoded", null, postData, _client.Proxy); return(result); }
protected string HttpGet(string url) { var header = new NameValueCollection { { "Accept-Language", "en-US" } }; return(RestfullRequest.Request(url, "GET", "application/x-www-form-urlencoded", header, null, _client.Proxy)); }
public override void RequestUserProfile() { var profileUrl = ApiUrlOauth + "/v1/identity/openidconnect/userinfo/?schema=openid"; var header = new NameValueCollection { {"Accept-Language", "en_US"}, {"Authorization", "Bearer " + _client.Token} }; var result = RestfullRequest.Request(profileUrl, "POST", "application/json", header, null, _client.Proxy); ParseUserData<PayPalUserData>(result); }
public string RequestToken() { string code = HttpContext.Current.Request.Params["code"]; if (code != null) { string tokenUrl = string.Format("https://login.live.com/oauth20_token.srf"); string post = string.Format("client_id={0}&redirect_uri={1}&target=self&client_secret={2}&code={3}&grant_type=authorization_code", HttpUtility.HtmlEncode(_client.ClientId), HttpUtility.HtmlEncode(_client.CallBackUrl), _client.ClientSecret, code); string resonseJson = RestfullRequest.Request(tokenUrl, "POST", "application/x-www-form-urlencoded", null, post, _client.Proxy); return(JsonConvert.DeserializeAnonymousType(resonseJson, new { access_token = "" }).access_token); } return("access_denied"); }
private void ExecuteRequest <T>(RestfullRequest <T> request, IObserver <T> observer, bool ignoreErrors = false) where T : class { request.Execute() .Subscribe(result => { _cache.Put(result, request.Url); observer.OnNext(result); }, ex => { if (!ignoreErrors) { observer.OnError(ex); } }, observer.OnCompleted); }
public string RequestToken() { string code = HttpContext.Current.Request.Params["code"]; if (code != null) { string tokenUrl = string.Format("https://graph.facebook.com/oauth/access_token?"); string post = string.Format("client_id={0}&redirect_uri={1}&client_secret={2}&code={3}", _client.ClientId, HttpUtility.HtmlEncode(_client.CallBackUrl), _client.ClientSecret, code); string resonseJson = RestfullRequest.Request(tokenUrl, "POST", "application/x-www-form-urlencoded", null, post, _client.Proxy); resonseJson = "{\"" + resonseJson.Replace("=", "\":\"").Replace("&", "\",\"") + "\"}"; return(JsonConvert.DeserializeAnonymousType(resonseJson, new { access_token = "" }).access_token); } return("access_denied"); }
protected IObservable <T> GetDataAsync <T>(RestfullRequest <T> request, CachePolicy cachePolicy = CachePolicy.GetFromCacheAndUpdate) where T : class { if (!_cache.IsCached <T>(request.Url)) { Debug.WriteLine("DataProvider::Getting data:" + request.Url); return(Observable.Create <T>( observer => Scheduler.Default.Schedule(() => ExecuteRequest(request, observer)) )); } Debug.WriteLine("DataProvider::Getting cached data:" + request.Url); return(Observable.Create <T>( observer => Scheduler.Default.Schedule(() => { var item = _cache.Fetch <T>(request.Url); observer.OnNext(item); if (cachePolicy == CachePolicy.TryGetFromCache) { observer.OnCompleted(); } else { var updatable = item as IUpdatableModel; if (updatable != null) { CheckIfNeededToBeUpdated(request, updatable, observer); } else { Debug.WriteLine("UpdateData:" + request.Url); ExecuteRequest(request, observer, true); } } }) )); }
public string RequestToken() { string code = HttpContext.Current.Request.Params["code"]; if (code != null) { string oauthUrl = OAUTH_API_URL + "/v1/identity/openidconnect/tokenservice"; //string oAuthCredentials = Convert.ToBase64String(Encoding.Default.GetBytes(_client.ClientId + ":" + _client.ClientSecret)); string post = string.Format("grant_type=authorization_code&redirect_uri={0}&code={1}&client_id={2}&client_secret={3}", HttpUtility.HtmlEncode(_client.CallBackUrl), code, _client.ClientId, _client.ClientSecret); string resonseJson = RestfullRequest.Request(oauthUrl, "POST", "application/x-www-form-urlencoded", null, post, _client.Proxy); return(JsonConvert.DeserializeAnonymousType(resonseJson, new { access_token = "" }).access_token); } return("access_denied"); }
private void CheckIfNeededToBeUpdated <T>(RestfullRequest <T> request, IUpdatableModel updatable, IObserver <T> observer) where T : class { var lastUpdated = updatable.LastUpdated; var lastUpdatedRequest = CallFactory.GetLastUpdatedRequest(request.ResourceUrl); Debug.WriteLine("WebClient::CheckIfNeededToBeUpdated " + lastUpdatedRequest.Url); lastUpdatedRequest.Execute() .Subscribe( resutl => { if (resutl.Data > lastUpdated) { Debug.WriteLine("WebClient::CheckIfNeededToBeUpdated::Updating " + request.Url); ExecuteRequest(request, observer); } else { observer.OnCompleted(); } }, ex => observer.OnCompleted()); }
protected IObservable <T> GetDataAsync <T>(RestfullRequest <T> request) where T : new() { if (!_cache.IsCached <T>(request.Url)) { Debug.WriteLine("Getting data:" + request.Url); return(Observable.Create <T>( observer => Scheduler.Default.Schedule(() => ExecuteRequest(request, observer)) )); } Debug.WriteLine("Getting cached data:" + request.Url); return(Observable.Create <T>( observer => Scheduler.Default.Schedule(() => { var item = _cache.Fetch <T>(request.Url); observer.OnNext(item); Debug.WriteLine("UpdateData:" + request.Url); ExecuteRequest(request, observer, true); }) )); }
public Dictionary <string, string> RequestUserProfile() { string profileUrl = string.Format("https://graph.facebook.com/me?access_token={0}", _client.Token); NameValueCollection header = new NameValueCollection(); header.Add("Accept-Language", "en-US"); string result = RestfullRequest.Request(profileUrl, "GET", "application/x-www-form-urlencoded", header, null, _client.Proxy); _client.ProfileJsonString = result; FacebookClient.UserProfile data = JsonConvert.DeserializeAnonymousType(result, new FacebookClient.UserProfile()); Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("source", "Facebook"); dictionary.Add("id", data.Id); dictionary.Add("name", data.Name); dictionary.Add("first_name", data.First_name); dictionary.Add("last_name", data.Last_name); dictionary.Add("link", data.Link); dictionary.Add("gender", data.Gender); dictionary.Add("email", data.Email); dictionary.Add("picture", data.Picture); return(dictionary); }
public RestfullRequest <Universities> GetAllUniversitesRequest() { return(RestfullRequest.Create <Universities>(UNIVERSITIES_ALL, _webService)); }
public RestfullRequest <Domain.Lessons.TimeTable> GetGroupTimeTableRequest(int groupId) { var suffix = string.Format(GROUP_TIMETABLE_TEMPLATE, groupId); return(RestfullRequest.Create <Domain.Lessons.TimeTable>(suffix, _webService)); }
public RestfullRequest <Domain.Lessons.TimeTable> GetTeacherTimeTableRequest(int id) { var suffix = string.Format(TEACHER_TIMETABLE_TEMPLATE, id); return(RestfullRequest.Create <Domain.Lessons.TimeTable>(suffix, _webService)); }
public RestfullRequest <Teachers> GetUniversityTeachersRequest(int universityId) { return(RestfullRequest.Create <Teachers>(InjectIdToTemplate(ALL_TEACHERS_TEMPLATE, universityId), _webService)); }
public RestfullRequest <Groups> GetFacultyGroupsRequest(int facultyId) { return(RestfullRequest.Create <Groups>(InjectIdToTemplate(ALL_GROUPS_TEMPLATE, facultyId), _webService)); }
public RestfullRequest <Faculties> GetUniversityFacultiesRequest(int universityId) { return(RestfullRequest.Create <Faculties>(InjectIdToTemplate(ALL_FACULTIES_TEMPLATE, universityId), _webService)); }
public RestfullRequest <LastUpdated> GetLastUpdatedRequest(string url) { return(RestfullRequest.Create <LastUpdated>(url + LAST_UPDATED, _webService)); }