public async Task <string> GetOAuthToken(string code) { var template = CloudConfigurationManager.GetSetting("YammerOAuthAccessUrl"); var url = template.Replace("%CODE%", code); var authEnvelope = await _client.GetAsync <YammerAccessToken>(new Uri(url)); return(authEnvelope.TokenResponse.Token); }
public async Task <string> GetOAuthToken(string code) { var template = CloudConfigurationManager.GetSetting("SlackOAuthAccessUrl"); var url = template.Replace("%CODE%", code); var jsonObj = await _client.GetAsync <JObject>(new Uri(url)); return(jsonObj.Value <string>("access_token")); }
public async Task <string> GetExternalUserId(GoogleAuthDTO googleAuthDTO) { var url = CloudConfigurationManager.GetSetting("GoogleUserProfileUrl"); url = url.Replace("%TOKEN%", googleAuthDTO.AccessToken); var jsonObj = await _client.GetAsync <JObject>(new Uri(url)); return(jsonObj.Value <string>("email")); }
public async Task <List <StatXGroupDTO> > GetGroups(StatXAuthDTO statXAuthDTO) { try { var uri = new Uri(StatXBaseApiUrl + "/groups"); var response = await _restfulServiceClient.GetAsync(uri, null, GetStatxAPIHeaders(statXAuthDTO)); var jObject = JObject.Parse(response); CheckForExistingErrors(jObject); var resultSet = new List <StatXGroupDTO>(); JToken dataToken; if (jObject.TryGetValue("data", out dataToken)) { if (dataToken is JArray) { resultSet.AddRange(dataToken.Select(item => new StatXGroupDTO() { Id = item["id"]?.ToString(), Name = item["name"]?.ToString(), Description = item["description"]?.ToString() })); } } return(resultSet); } catch (RestfulServiceException exception) { var jObject = JObject.Parse(exception.ResponseMessage); JToken errorsToken; if (jObject.TryGetValue("errors", out errorsToken)) { if (errorsToken is JArray) { var firstError = (JObject)errorsToken.First; throw new ApplicationException($"StatX request error: {firstError["message"]?.ToString()}"); } } return(new List <StatXGroupDTO>()); } }
public async Task <TResponse> GetAsync <TResponse>(Uri requestUri, string CorrelationId = null, Dictionary <string, string> headers = null) { var header = await PrepareHeader(headers); var response = await _restfulClient.GetAsync <TResponse>(requestUri, CorrelationId, header); return(response); }
// Get the Design time fields crate. private async Task <Crate> GetDesignTimeFieldsCrateOfSelectedFr8Object(string fr8Object) { var url = CloudConfigurationManager.GetSetting("DefaultHubUrl") + "api/" + CloudConfigurationManager.GetSetting("HubApiVersion") + "/manifests?id=" + int.Parse(fr8Object); var response = await _restfulServiceClient.GetAsync <CrateDTO>(new Uri(url)); return(CrateStorageSerializer.Default.ConvertFromDto(response)); }
private async Task <TResponse> ApiGetAsync <TResponse>(string apiUrl, BasecampAuthorizationToken auth) { return(await _restfulServiceClient.GetAsync <TResponse>(new Uri(apiUrl), headers : GetHeaders(auth)).ConfigureAwait(false)); }
private async Task <StandardFr8TerminalCM> SendDiscoveryRequest(string terminalUrl, Dictionary <string, string> headers = null) { return(await _restfulServiceClient.GetAsync <StandardFr8TerminalCM>(new Uri(terminalUrl + "/discover", UriKind.Absolute), null, headers)); }
public async Task <PayloadDTO> GetPayload(Guid containerId) { var uri = new Uri($"{GetHubUrlWithApiVersion()}/containers/payload?id={containerId.ToString("D")}", UriKind.Absolute); var payloadDTOTask = await _restfulServiceClient.GetAsync <PayloadDTO>(uri, containerId.ToString(), await GetHMACHeader(uri)); return(payloadDTOTask); }
public async Task <UserData> GetUserInfo(string oauthToken) { var response = await _client.GetAsync <JObject>(new Uri("https://api.instagram.com/v1/users/self/?access_token=" + oauthToken)); return(response.ToObject <UserData>()); }
public async Task <FacebookPost> GetPostById(string oauthToken, string postId) { var postData = await _rsc.GetAsync <GraphApiPostReply>(GetAbsoluteUri($"me/feed?id={postId}", oauthToken)); return(postData?.data.FirstOrDefault()); }