August 19, 2019 at 5:59 am
we need to pull data from TAP API (OAUTH2.0), where we need to pass authentic key + client-id+secret key in the web service url. Authentic key validity is only 15 mins and for every 15 mins i need to regenerate new authentic key. So i am looking for how can we generate authentic key using script Component.
FYI.. i am able to pull the data using direct API, PFB script for the same. But i am looking more into how can i generate authentic key and , how can i add that key into main url.
below is the API code.
#region Help: Introduction to the Script Component
/* The Script Component allows you to perform virtually any operation that can be accomplished in
* a .Net application within the context of an Integration Services data flow.
*
* Expand the other regions which have "Help" prefixes for examples of specific ways to use
* Integration Services features within this script component. */
#endregion
#region Namespaces
using System;
using System.Data;
using System.Net;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
#endregion
/// <summary>
/// This is the class to which to add your code. Do not change the name, attributes, or parent
/// of this class.
/// </summary>
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
/// <summary>
/// This method is called once, before rows begin to be processed in the data flow.
///
/// You can remove this method if you don't need to do anything here.
/// </summary>
public override void PreExecute()
{
base.PreExecute();
try
{
//denodoJSONRequest = new WebClient();
//denodoJSONRequest.UseDefaultCredentials = true;
//denodoJSONRequest.Credentials = new NetworkCredential(denodoUser, denodoPsswd);
//denodoJSONResponse = denodoJSONRequest.DownloadString(DenodoRequestURL);
}
catch (Exception ex)
{
}
}
/// <summary>
/// This method is called after all the rows have passed through this component.
///
/// You can delete this method if you don't need to do anything here.
/// </summary>
public override void PostExecute()
{
base.PostExecute();
/*
* Add your code here
*/
}
public override void CreateNewOutputRows()
{
string DenodoRequestURL = Variables.PDenodoURL;
string denodoUser = Variables.PDenodoUser;
string denodoPsswd = Variables.PDenodoPsswd;
WebClient denodoJSONRequest;
string denodoJSONResponse;
denodoJSONRequest = new WebClient();
denodoJSONRequest.UseDefaultCredentials = true;
denodoJSONRequest.Credentials = new NetworkCredential(denodoUser, denodoPsswd);
denodoJSONResponse = denodoJSONRequest.DownloadString(DenodoRequestURL);
if (!String.IsNullOrEmpty(denodoJSONResponse))
{
JObject jsonObject = JObject.Parse(denodoJSONResponse);
JToken jsonElements = jsonObject["elements"];
foreach (var json in jsonElements)
{
DenodoResponseBuffer.AddRow();
DenodoResponseBuffer.column1 = int.Parse(json["column1"].ToString().Trim());
DenodoResponseBuffer.column2 = int.Parse(json["column2"].ToString().Trim());
DenodoResponseBuffer.column3 = json["column3"].ToString().Trim();
DenodoResponseBuffer.column4 = json["column4"].ToString().Trim();
DenodoResponseBuffer.column5 = DateTime.Parse(json["column5"].ToString().Trim());
DenodoResponseBuffer.column6 = DateTime.Parse(json["column6"].ToString().Trim());
}
}
}
}
August 20, 2019 at 6:10 am
Thanks for posting your issue and hopefully someone will answer soon.
This is an automated bump to increase visibility of your question.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy