{"id":6789,"date":"2019-04-19T13:49:45","date_gmt":"2019-04-19T13:49:45","guid":{"rendered":"https:\/\/zappysys.com\/blog\/?p=6789"},"modified":"2019-04-22T22:37:52","modified_gmt":"2019-04-22T22:37:52","slug":"using-hmac-authentication-api-ssis-odbc-drivers","status":"publish","type":"post","link":"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/","title":{"rendered":"Using HMAC Authentication for API in SSIS \/ ODBC Drivers"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>In this post we will see how to call API which uses HMAC Authentication (MD5 or SHA HASH Signature). Almost everywhere example you search online will talk about writing code (i.e. Python, C#, Java) if you need to use HMAC Authentication to call you REST API, however in this article we will discuss coding-free approach for your Data Integration. We will see example in SSIS and then ODBC Driver (SQL Query approach) to read \/ write data from REST API with HMAC Authentication (SHA-256 Hashing).<\/p>\n<div class=\"content_block\" id=\"custom_post_widget-2523\"><h2><span id=\"Prerequisites\">Prerequisites<\/span><\/h2>\r\nBefore we perform the steps listed in this article, you will need to make sure the following prerequisites are met:\r\n<ol style=\"margin-left: 1.5em;\">\r\n \t<li><abbr title=\"SQL Server Integration Services\">SSIS<\/abbr> designer installed.\u00a0Sometimes it is referred to as <abbr title=\"Business Intelligence Development Studio\">BIDS<\/abbr> or <abbr title=\"SQL Server Data Tools\">SSDT<\/abbr> (<a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/ssdt\/download-sql-server-data-tools-ssdt\" target=\"_blank\" rel=\"noopener\">download it from the Microsoft site<\/a>).<\/li>\r\n \t<li>Basic knowledge of SSIS package\u00a0development using\u00a0<em>Microsoft SQL Server Integration Services<\/em>.<\/li>\r\n \t<li>Make sure\u00a0<span style=\"text-decoration: underline;\"><a href=\"https:\/\/zappysys.com\/products\/ssis-powerpack\/\" target=\"_blank\" rel=\"noopener\">ZappySys SSIS PowerPack<\/a><\/span>\u00a0is installed (<a href=\"https:\/\/zappysys.com\/products\/ssis-powerpack\/download\/\" target=\"_blank\" rel=\"noopener\">download it<\/a>, if you haven't already).<\/li>\r\n \t<li>(<em>Optional step<\/em>)<em>.<\/em>\u00a0<a href=\"https:\/\/zappysys.zendesk.com\/hc\/en-us\/articles\/360035974593\" target=\"_blank\" rel=\"noopener\">Read this article<\/a>, if you are planning to deploy packages to a server and schedule their execution later.<\/li>\r\n<\/ol><\/div>\n<h2>What is HMAC Authentication<\/h2>\n<p>If you are new to HMAC term then please check Wiki description <a href=\"https:\/\/en.wikipedia.org\/wiki\/HMAC\">here<\/a>. Basically in HMAC Authentication you create a unique signature by hashing API Request (i.e. URL, Method, Body) using secret key \/ password. Once server receives your data it tries to validate signature. Unlike other authentication methods, in HMAC Auth your Secret key is never transmitted so in order to alter message by middle man, attacker has to gain access to your secret key before he can recreate signature to alter your message.<\/p>\n<h2>Example APIs which uses HMAC Authentication<\/h2>\n<p>Here is a list of few API providers which we tested to support HMAC. There many more APIs out there which should also work but we have not tested.<\/p>\n<ul>\n<li><strong>Microsoft Azure CosmosDB<\/strong> (formally known as DocumentDB) uses HMAC Signature &#8211; <a href=\"https:\/\/docs.microsoft.com\/en-us\/rest\/api\/cosmos-db\/access-control-on-cosmosdb-resources?redirectedfrom=MSDN\" target=\"_blank\" rel=\"noopener\">See API documentation here<\/a><\/li>\n<li><strong>CSOD<\/strong> uses HMAC (This is <a href=\"https:\/\/zappysys.com\/blog\/call-soap-rest-api-using-dynamic-token-ssis\/\" target=\"_blank\" rel=\"noopener\">2 steps Dynamic Token<\/a> approach) &#8211; <a href=\"https:\/\/apiexplorer.csod.com\/apiconnectorweb\/apiexplorer#\/apidoc\/59aa5211-b2c9-45af-97b1-0c0902dc4060\" target=\"_blank\" rel=\"noopener\">See API documentation here<\/a><\/li>\n<li><strong>Acquia<\/strong> uses HMAC &#8211; <a href=\"https:\/\/docs.acquia.com\/lift\/api\/hmacv2\/#creating-authheader\" target=\"_blank\" rel=\"noopener\">See API documentation here<\/a><\/li>\n<li><strong>Amazon AWS<\/strong> Cloud uses HMAC Signature &#8211; ZappySys uses\u00a0<a href=\"https:\/\/zappysys.com\/blog\/how-to-call-amazon-aws-api-using-ssis-ec2-lambda-api-gateway-sqs\/\" target=\"_blank\" rel=\"noopener\">this approach<\/a>\u00a0to call AWS APIs with <a href=\"https:\/\/docs.aws.amazon.com\/general\/latest\/gr\/sigv4-create-canonical-request.html\">AWS v4 Signature<\/a>.<\/li>\n<\/ul>\n<p>New HMAC Authentication feature of ZappySys HTTP Connection can be used in SSIS connectors \/ ODBC Drivers for REST. Use HTTP connection for all HMAC scenarios except AWS. For AWS we make it very simple by using dedicated\u00a0<a href=\"https:\/\/zappysys.com\/blog\/how-to-call-amazon-aws-api-using-ssis-ec2-lambda-api-gateway-sqs\/\" target=\"_blank\" rel=\"noopener\">OAuth Provider for AWS v4<\/a>.<\/p>\n<h2>Pros and Cons of HMAC Authentication<\/h2>\n<p>Now let&#8217;s look at what are some pros and cons of HMAC Authentication.<\/p>\n<h3>Advantages of HMAC Authentication<\/h3>\n<ul>\n<li>Unlike other Authentication methods like <a href=\"https:\/\/zappysys.com\/blog\/how-to-set-base64-encoded-authorization-header-for-http-web-request\/\" target=\"_blank\" rel=\"noopener\">Basic Authentication<\/a> or <a href=\"https:\/\/zappysys.com\/blog\/rest-api-authentication-with-oauth-2-0-using-ssis\/\" target=\"_blank\" rel=\"noopener\">OAuth 2<\/a>, you dont have to pass Secret Key \/ Password along with your request<\/li>\n<li>SSL is optional so you can host your API over HTTP rather than HTTPS (However its strongly suggested that you always use HTTPS when possible)<\/li>\n<li>You can avoid Replay attack because Requests are Hashed along with some Timestamp, so after few mins most servers will reject the signature if same request is retried again by attacker.<\/li>\n<\/ul>\n<h3>Disadvantages of HMAC Authentication<\/h3>\n<ul>\n<li>It is very complex compared to other approaches. <a href=\"https:\/\/docs.aws.amazon.com\/general\/latest\/gr\/sigv4-create-canonical-request.html\">Here is an example (AWS Signature)\u00a0<\/a> of how complex it can be :).<\/li>\n<li>You need to have Cryptography Libraries Access in order to HASH with correct algorithm<\/li>\n<\/ul>\n<p>Anyways enough said now lets see something in Action.<\/p>\n<h2>HMAC Authentication Example for SSIS<\/h2>\n<p>So to demo how HMAC Authentication can be implemented in SSIS we will use <a href=\"https:\/\/docs.microsoft.com\/en-us\/rest\/api\/cosmos-db\/access-control-on-cosmosdb-resources\" target=\"_blank\" rel=\"noopener\">Azure CosmosDB API<\/a> which uses HMAC Authentication.<\/p>\n<ol>\n<li>Open existing SSIS Solution or create new Project<\/li>\n<li>From SSIS Toolbox drag and drop ZS REST API Task\n<div style=\"width: 565px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full\" src=\"https:\/\/zappysys.com\/onlinehelp\/ssis-powerpack\/scr\/images\/rest-api-task\/ssis-rest-api-web-service-task-drag.png\" alt=\"Drag and Drop REST API Task from SSIS Toolbox\" width=\"555\" height=\"199\" \/><p class=\"wp-caption-text\">Drag and Drop REST API Task from SSIS Toolbox<\/p><\/div><\/li>\n<li>Now let&#8217;s, Configure HTTP Connection as below<\/li>\n<li>Right click on\u00a0<b>Connection Managers<\/b>\u00a0Panel to Create HTTP Connection, Select New Connection from the Context Menu.<br \/>\n<img decoding=\"async\" class=\"figureimage\" title=\"SSIS REST Api Web Service Task - Create Connection\" src=\"https:\/\/zappysys.com\/onlinehelp\/ssis-powerpack\/scr\/images\/ssis-new-connection.png\" alt=\"SSIS REST Api Task - Create Connection\" \/><\/li>\n<li>Select\u00a0<b>ZS-HTTP<\/b>\u00a0Connection Manager from the\u00a0<b>Connection Managers<\/b>\u00a0list and Click on Add Button<br \/>\n<img decoding=\"async\" class=\"figureimage\" title=\"SSIS REST Api Web Service Task - Create Connection\" src=\"https:\/\/zappysys.com\/onlinehelp\/ssis-powerpack\/scr\/images\/rest-api-task\/ssis-rest-api-web-service-task-http-connection.png\" alt=\"SSIS REST Api Task - Create Connection\" \/><\/li>\n<li>Once HTTP Connection UI is visible select HMAC Authentication option, enter User ID and Password or API Key as below. If CosmosDB API example ignore Username and enter master API key. You can enter any valid URL (We will override this in next step anyways). Click on <strong>Configure HMAC Signature<\/strong> link.\n<div id=\"attachment_6846\" style=\"width: 866px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-http-connection-hmac-authentication.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-6846\" class=\"size-full wp-image-6846\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-http-connection-hmac-authentication.png\" alt=\"HTTP Connection with HMAC Authentication Option (Azure CosmosDB API Example)\" width=\"856\" height=\"413\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-http-connection-hmac-authentication.png 856w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-http-connection-hmac-authentication-300x145.png 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-http-connection-hmac-authentication-768x371.png 768w\" sizes=\"(max-width: 856px) 100vw, 856px\" \/><\/a><p id=\"caption-attachment-6846\" class=\"wp-caption-text\">HTTP Connection with HMAC Authentication Option (Azure CosmosDB API Example)<\/p><\/div><\/li>\n<li>Enter following 4 pieces to create correct HMAC Signature for Azure CosmosDB API call.\n<div id=\"attachment_6847\" style=\"width: 811px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/configure-http-rest-api-hmac-authentication-sha256-signature.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-6847\" class=\"size-full wp-image-6847\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/configure-http-rest-api-hmac-authentication-sha256-signature.png\" alt=\"Configure HMAC String To Sign, Headers, Timestamp format, Algorithm\" width=\"801\" height=\"553\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/configure-http-rest-api-hmac-authentication-sha256-signature.png 801w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/configure-http-rest-api-hmac-authentication-sha256-signature-300x207.png 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/configure-http-rest-api-hmac-authentication-sha256-signature-768x530.png 768w\" sizes=\"(max-width: 801px) 100vw, 801px\" \/><\/a><p id=\"caption-attachment-6847\" class=\"wp-caption-text\">Configure HMAC String To Sign, Headers, Timestamp format, Algorithm<\/p><\/div>\n<ol>\n<li>Select <strong>HMAC algorithm<\/strong> as <span class=\"lang:default highlight:0 decode:true crayon-inline \">sha256<\/span>\u00a0 \u00a0this is the most common algorithm for hashing and used by many APIs. Few other possible choices would be sha1, sha512, md5 and any other valid name from your system.<\/li>\n<li>Enter <strong>String To Sign<\/strong>. Refer to your API and see how its expecting you to build this string. Each API may have different pieces in different order so be careful to define this else Signature will not match with server signature. In <strong>Azure CosmosDB API<\/strong> we use <a href=\"https:\/\/docs.microsoft.com\/en-us\/rest\/api\/cosmos-db\/access-control-on-cosmosdb-resources\" target=\"_blank\" rel=\"noopener\">this documentation<\/a> to understand. Refer to <a href=\"https:\/\/zappysys.com\/onlinehelp\/ssis-powerpack\/scr\/ssis-http-connection-manager.htm\">HTTP Connection Manager<\/a> help file or See next section to learn about all possible placeholders.\n<pre class=\"lang:default highlight:0 decode:true\">[$http-method$]-lc[$lf$][$url-part-right-1$]-lc[$lf$][$url-part-right-2-4$][$lf$][$timestamp$]-lc[$lf$][$lf$]<\/pre>\n<p>Where<br \/>\n<strong>[$lf$]<\/strong>\u00a0is new line (i.e. \\n)<br \/>\n<strong>[$http-method$]<\/strong> is your HTTP Request Method (i.e. GET, POST, DELETE&#8230;)<br \/>\n<strong>[$url-part-right-1$]<\/strong> will extract first part from right side in URL Path (e.g.\u00a0colls if URL is\u00a0https:\/\/zappycosmos.documents.azure.com\/dbs\/northwind\/colls)<br \/>\n<strong>[$url-part-right-2-4$]<\/strong> will extract string from 2nd part from right till 4th part from left (e.g.\u00a0dbs\/northwind if URL is\u00a0https:\/\/zappycosmos.documents.azure.com\/dbs\/northwind\/colls)<br \/>\n<strong>[$timestamp$]<\/strong> will return current time in UTC in specified format (see next)<br \/>\n<strong>-lc suffix<\/strong>\u00a0in some placeholders will return value in lowercase. e.g.\u00a0<strong>[$http-method$]-lc<\/strong>\u00a0 will return <strong>get<\/strong> rather than <strong>GET<\/strong><\/p>\n<p>Example Request:<\/p>\n<pre class=\"lang:default highlight:0 decode:true\">GET https:\/\/zappycosmos.documents.azure.com\/dbs\/northwind\/colls HTTP\/1.1\r\nx-ms-date: Mon, 22 Apr 2019 20:59:20 GMT<\/pre>\n<p>String To Sign at runtime this may be like below<\/p>\n<pre class=\"lang:default highlight:0 decode:true\">get\\n\r\ncolls\\n\r\ndbs\/northwind\\n\r\nmon, 22 apr 2019 20:59:20 gmt\\n\r\n\\n\r\n\\n<\/pre>\n<\/li>\n<li>Enter <strong>Extra Headers<\/strong> as below to make sure each REST API call includes <strong>x-ms-date<\/strong> ,\u00a0<strong>x-ms-version<\/strong> and\u00a0<strong>Authorization<\/strong> header.\u00a0 See next section to learn about all possible placeholders. In below format we used\u00a0<strong>[$signature$]-enc<\/strong> which means Base64 Signature string in URL encoded format. Remove -enc if API doesn&#8217;t need URL encoded string.\n<pre class=\"lang:default highlight:0 decode:true\">x-ms-date: [$timestamp$]||x-ms-version: 2015-08-06||Authorization:type%3dmaster%26ver%3d1.0%26sig%3d[$signature$]-enc<\/pre>\n<\/li>\n<li>Enter <strong>Timestamp format<\/strong> as <span class=\"lang:default highlight:0 decode:true crayon-inline\">r<\/span>\u00a0 this will produce date as <span class=\"lang:default highlight:0 decode:true crayon-inline \">Mon, 22 Apr 2019 20:48:26 GMT<\/span>\u00a0 for example. Refer to API for exact date time format. <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/base-types\/custom-date-and-time-format-strings\" target=\"_blank\" rel=\"noopener\">These are<\/a> supported format specifiers. <span class=\"lang:default highlight:0 decode:true crayon-inline\">r<\/span>\u00a0 OR\u00a0<span class=\"lang:default highlight:0 decode:true crayon-inline\">R<\/span>\u00a0\u00a0is <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/base-types\/standard-date-and-time-format-strings#the-rfc1123-r-r-format-specifier\" target=\"_blank\" rel=\"noopener\">RFC 1123 standard format<\/a>.<\/li>\n<\/ol>\n<\/li>\n<li>That ist now click OK to save HMAC Auth settings and on REST API Task check Use Direct URL option and enter URL like below to Fetch List of all collections. Replace <strong>MY-HOST<\/strong> and <strong>MY-DATABASE<\/strong> with your own values.\n<pre class=\"lang:default highlight:0 decode:true\">https:\/\/MY-HOST.documents.azure.com\/dbs\/MY-DATABASE\/colls<\/pre>\n<\/li>\n<li>Click Test and see it returns status 200 OK\n<div id=\"attachment_6842\" style=\"width: 749px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-call-azure-cosmosdb-rest-api-get-documentdb-table-list.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-6842\" class=\"wp-image-6842 size-full\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-call-azure-cosmosdb-rest-api-get-documentdb-table-list.png\" alt=\"Call Azure CosmosDB REST API in SSIS (List DocumentDB Tables Example)\" width=\"739\" height=\"591\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-call-azure-cosmosdb-rest-api-get-documentdb-table-list.png 739w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-call-azure-cosmosdb-rest-api-get-documentdb-table-list-300x240.png 300w\" sizes=\"(max-width: 739px) 100vw, 739px\" \/><\/a><p id=\"caption-attachment-6842\" class=\"wp-caption-text\">Call Azure CosmosDB REST API in SSIS (List DocumentDB Tables Example)<\/p><\/div><\/li>\n<\/ol>\n<h2>HMAC Authentication Example for ODBC Drivers<\/h2>\n<p>Same example above can be achieved using following SQL Query described in below section using\u00a0<a href=\"https:\/\/zappysys.com\/products\/odbc-powerpack\/odbc-json-rest-api-driver\/\" target=\"_blank\" rel=\"noopener\">ODBC PowerPack using JSON \/ REST API Driver<\/a><\/p>\n<p>Use below steps to try HMAC feature which calls CosmosDB API. Now lets look at step by step.<\/p>\n<ol>\n<li>Install ODBC PowerPack (It includes <a href=\"https:\/\/zappysys.com\/products\/odbc-powerpack\/odbc-json-rest-api-driver\/\" target=\"_blank\" rel=\"noopener\">JSON Driver for REST API \/ Files<\/a>)<\/li>\n<li>Type odbc in start menu and select ODBC Data Sources (64-bit)<\/li>\n<li>\u00a0Click New to add new DSN and select ZappySys JSON Driver<\/li>\n<li>When JSON Driver UI is visible click on Load Connection String Button and enter below string and click OK. Before you can load you can change DataPath, Password, RequestData properties as per your need. You can also change later on too once loaded.\n<pre class=\"lang:default highlight:0 decode:true\">DRIVER={ZappySys JSON Driver};DataPath='https:\/\/MY-HOST.documents.azure.com\/dbs\/MY-DATABASE\/colls\/MY-TABLE\/docs';DataConnectionType=HTTP;UserName='MY-HOST';HashTimestampFormat='r';ExtraHeaders='x-ms-date: [$timestamp$]||x-ms-version: 2015-08-06||Authorization:type%3dmaster%26ver%3d1.0%26sig%3d[$signature$]-enc';HashSignatureFormat='[$http-method$]-lc[$lf$][$url-part-right-1$]-lc[$lf$][$url-part-right-2-4$][$lf$][$timestamp$]-lc[$lf$][$lf$]';CredentialType=HashSignature;Password='xxxxxxxxxxxxxxxxxxxxxxxx==';Filter='$.Documents[*]';RequestData='{\"query\":\"SELECT * FROM root\"}';RequestMethod='POST';PagingMode=ByResponseHeaderContinuationToken;PagingByUrlAttributeName='x-ms-continuation,x-ms-session-token';RequestHeaders='Content-Type: application\/query+json || x-ms-documentdb-query-enablecrosspartition: true || x-ms-documentdb-isquery: true'<\/pre>\n<\/li>\n<li>Now go to preview tab and click execute to see preview data.<\/li>\n<li>Here is Full query to override one or more connection attributes per query\n<pre class=\"lang:default highlight:0 decode:true\">SELECT * FROM $\r\nWITH(\r\n\t Src='https:\/\/MY-HOST-NAME.documents.azure.com\/dbs\/MY-DB-NAME\/colls\/MY-TABLE-NAME\/docs'\r\n\t,DataConnectionType='HTTP'\r\n\t,UserName='MY-HOST-NAME'\r\n\t,HashTimestampFormat='r'\r\n\t,ExtraHeaders='x-ms-date: [$timestamp$]||x-ms-version: 2015-08-06||Authorization:type%3dmaster%26ver%3d1.0%26sig%3d[$signature$]-enc'\r\n\t,HashSignatureFormat='[$http-method$]-lc[$lf$][$url-part-right-1$]-lc[$lf$][$url-part-right-2-4$][$lf$][$timestamp$]-lc[$lf$][$lf$]'\r\n\t,CredentialType='HashSignature'\r\n\t,Password='Hfs7k5wxxxxxxxxxxxxxxxxxxxxxxxxx4Ue0eucwDHMg=='\r\n\t,Filter='$.Documents[*]'\r\n\t,RequestData='{\"query\":\"SELECT * FROM root\"}'\r\n\t,Header='Content-Type: application\/query+json || x-ms-documentdb-query-enablecrosspartition: true || x-ms-documentdb-isquery: true'\r\n\t,RequestMethod='POST'\r\n\t,PagingMode='ByResponseHeaderContinuationToken'\r\n\t,PagingByUrlAttributeName='x-ms-continuation,x-ms-session-token'\r\n\t--,PagingByUrlMaxPages='4'\r\n)<\/pre>\n<p>In above Query replace\u00a0Src, Password and RequestData (if you need different SQL).<\/p>\n<ul>\n<li>Change Src to correct URL to (first part and Resource Link (MY-HOST-NAME , MY-DB-NAME, and MY-TABLE-NAME)<br \/>\nExample:<br \/>\nhttps:\/\/zappycosmos.documents.azure.com\/dbs\/northwind\/colls\/customers\/docs<br \/>\nor (using explicite region)<br \/>\nhttps:\/\/zappycosmos-eastus.documents.azure.com\/dbs\/northwind\/colls\/customers\/docs<\/li>\n<li>Change\u00a0Password with your Key, change username with something (e.g. instance name) this is ignored for CosmosDB API so enter anything.<\/li>\n<li>Change RequestData with desired SQL query you like to execute or leave it default to return all.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<div id=\"attachment_6843\" style=\"width: 818px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/azure-cosmosdb-driver-odbc-example-sql-query.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-6843\" class=\"size-full wp-image-6843\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/azure-cosmosdb-driver-odbc-example-sql-query.png\" alt=\"Query CosmosDB Documents using ODBC Driver (JSON \/ REST API)\" width=\"808\" height=\"766\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/azure-cosmosdb-driver-odbc-example-sql-query.png 808w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/azure-cosmosdb-driver-odbc-example-sql-query-300x284.png 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/azure-cosmosdb-driver-odbc-example-sql-query-768x728.png 768w\" sizes=\"(max-width: 808px) 100vw, 808px\" \/><\/a><p id=\"caption-attachment-6843\" class=\"wp-caption-text\">Query CosmosDB Documents using ODBC Driver (JSON \/ REST API)<\/p><\/div>\n<p>&nbsp;<\/p>\n<h2>Supported Placeholders for String To Sign and Extra Headers<\/h2>\n<p>Now let&#8217;s look at various placeholders you can use in String to Sign and Extra Headers Setting we saw earlier.<\/p>\n<p><strong>Placeholder Modifiers<\/strong><\/p>\n<p>-lc\u00a0 : Output as Lower Case\u00a0 ( Example ABCD will be returned as abcd)<\/p>\n<p>-enc : Output as URL Encoded\u00a0 (Example:\u00a0 A=B will be encoded as A%3DB )<\/p>\n<p><strong>Placeholders<\/strong><\/p>\n<div class=\"su-table su-table-alternate\">\n<table style=\"border-collapse: collapse;width: 100%\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"width: 50%\">Placeholder<\/td>\n<td style=\"width: 50%\">Description<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$lf$]<\/td>\n<td style=\"width: 50%\">Indicates Newline (same as \\n)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$userid$]<\/td>\n<td style=\"width: 50%\">Your userid or account id entered in UserName property<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$http-method$]<\/td>\n<td style=\"width: 50%\">Indicates HTTP Verb for current request (e.g GET, POST, PUT, HEAD, DELETE)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$host$]<\/td>\n<td style=\"width: 50%\">Host name part from URL (e.g. www.zappysys.com for https:\/\/www.zappysys.com\/someapi)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$url-relative$]<\/td>\n<td style=\"width: 50%\">Indicates URL path of current request. This part is after host name and before ? if parameters used (e.g \/api\/v1\/customers for http:\/\/a.com\/api\/v1\/customers?id=123)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$url-query$]<\/td>\n<td style=\"width: 50%\">URL parameters (key and value pairs) (e.g. for http:\/\/a.com\/api\/v1\/customers?z=123&amp;a=true it will return z=123&amp;a=true)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$url-query-canonical$]<\/td>\n<td style=\"width: 50%\">URL parameters in Canonical Format (key and value pairs are sorted by key. Key is returned as lowercase and both key+value URL encoded) (e.g. for http:\/\/a.com\/api\/v1\/customers?Zebra=Good&amp;Apple Cake=Yummy &#8230;it will return apple%20cake=Yummy&amp;zebra=Good)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$url-part-[left|right]-N1[-N2]$]<\/td>\n<td style=\"width: 50%\">URL part from left or right. N1 is start position, N2 is optional and its end position (e.g. for http:\/\/a.com\/api\/v1\/customers?z=123&amp;a=true [$url-part-right-1$] should give you customers and [$url-part-right-2$] returns v1). [$url-part-right-1-1$] should return http:\/\/a.com\/api\/v1\/customers and [$url-part-left-3-1$] should return a.com\/api\/v1\/customers (3rd from left till last part)<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$timestamp$]<\/td>\n<td style=\"width: 50%\">Indicates Current Timestamp in UTC (Use <strong>TimestampFormat<\/strong> property to change default Date Format which is ISO. To use Unix based time enter epoch, for custom format use something like yyyy-MM-ddTHH:mm:ss.fffZ for ISO. For custom date format specifiers <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/base-types\/custom-date-and-time-format-strings\" target=\"_blank\" rel=\"noopener\">click here<\/a> and to see Standard Formats <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/base-types\/standard-date-and-time-format-strings\" target=\"_blank\" rel=\"noopener\">click here<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$nounce$]<\/td>\n<td style=\"width: 50%\">A unique random string (e.g. nounce). This is sometimes asked by provider to put in signature to avoid replay attack.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$body-hash-ALGORITHM$]\n[$body-hash-ALGORITHM[-hex][-ke]$]<\/td>\n<td style=\"width: 50%\">(example: [$body-hash-sha256-hex$] or [$body-hash-sha256$]) This placeholder is for HASH of supplied body for current request. Replace ALGORITHM with valid name (e.g. md5, sha1, sha256, sha512). Also to Output Hash as lowercase Alphanumeric Hex suffix by -hex (e.g. [$body-hash-sha256-hex$] ). By default this placeholder is not included for GET \/ HEAD requests (We remove HASH and trailing \\n for GET \/ HEAD requests). To include Body HASH regardless request Method you need to add -ke (Keep Empty) suffix. e.g. [$body-hash-sha256-ke$]<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$content-type[-ke]$]<\/td>\n<td style=\"width: 50%\">(example: [$content-type$] or [$content-type-ke$]) This placeholder is to indicate request COntent-Type (e.g. application\/json). By default this placeholder is not included for GET \/ HEAD requests (We remove content-type from String Format along with trailing \\n for GET \/ HEAD requests). To include Body content-type regardless request method you need to add -ke (Keep Empty) suffix. e.g. [$content-type-ke$]<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$signature$]<\/td>\n<td style=\"width: 50%\">Signature in base64 format. This is calculated based on HashSignatureFormat string.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$signature-hex$]<\/td>\n<td style=\"width: 50%\">Signature in lowercase Hex format. This is calculated based on HashSignatureFormat string.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">[$token$]<\/td>\n<td style=\"width: 50%\">If you using <a href=\"https:\/\/zappysys.com\/blog\/call-soap-rest-api-using-dynamic-token-ssis\/\" target=\"_blank\" rel=\"noopener\">DynamicToken method<\/a> to login first and then extract token to call next API then you can use this placeholder for Headers.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2>Conclusion<\/h2>\n<p>In this article you saw how ZappySys made it possible to call virtually any API using powerful SSIS Connectors for JSON \/ XML API and also ZappySys ODBC Drivers to integrate in any ODBC compliant apps like Excel, Power BI, Qlik, SSRS and many more.\u00a0 Download FREE Trial of <a href=\"https:\/\/zappysys.com\/products\/ssis-powerpack\/\">SSIS PowerPack<\/a> and <a href=\"https:\/\/zappysys.com\/products\/odbc-powerpack\/\">ODBC PowerPack<\/a> depending on your use case.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In this post we will see how to call API which uses HMAC Authentication (MD5 or SHA HASH Signature). Almost everywhere example you search online will talk about writing code (i.e. Python, C#, Java) if you need to use HMAC Authentication to call you REST API, however in this article we will discuss coding-free [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6846,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\r\n<title>Using HMAC Authentication for API in SSIS \/ ODBC Drivers | ZappySys Blog<\/title>\r\n<meta name=\"description\" content=\"Using HMAC Authentication for API in SSIS \/ ODBC Drivers - ZappySys Blog\" \/>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"Using HMAC Authentication for API in SSIS \/ ODBC Drivers | ZappySys Blog\" \/>\r\n<meta property=\"og:description\" content=\"Using HMAC Authentication for API in SSIS \/ ODBC Drivers - ZappySys Blog\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/\" \/>\r\n<meta property=\"og:site_name\" content=\"ZappySys Blog\" \/>\r\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/ZappySys\/\" \/>\r\n<meta property=\"article:published_time\" content=\"2019-04-19T13:49:45+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2019-04-22T22:37:52+00:00\" \/>\r\n<meta property=\"og:image\" content=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-http-connection-hmac-authentication.png\" \/>\r\n\t<meta property=\"og:image:width\" content=\"856\" \/>\r\n\t<meta property=\"og:image:height\" content=\"413\" \/>\r\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\r\n<meta name=\"author\" content=\"ZappySys\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/zappysys\/\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ZappySys\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/\",\"url\":\"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/\",\"name\":\"Using HMAC Authentication for API in SSIS \/ ODBC Drivers | ZappySys Blog\",\"isPartOf\":{\"@id\":\"https:\/\/zappysys.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-http-connection-hmac-authentication.png\",\"datePublished\":\"2019-04-19T13:49:45+00:00\",\"dateModified\":\"2019-04-22T22:37:52+00:00\",\"author\":{\"@id\":\"https:\/\/zappysys.com\/blog\/#\/schema\/person\/2756c237457fbc95d82cb38962f81f82\"},\"description\":\"Using HMAC Authentication for API in SSIS \/ ODBC Drivers - ZappySys Blog\",\"breadcrumb\":{\"@id\":\"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/#primaryimage\",\"url\":\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-http-connection-hmac-authentication.png\",\"contentUrl\":\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-http-connection-hmac-authentication.png\",\"width\":856,\"height\":413,\"caption\":\"HTTP Connection with HMAC Authentication Option (Azure CosmosDB API Example)\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/zappysys.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using HMAC Authentication for API in SSIS \/ ODBC Drivers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/zappysys.com\/blog\/#website\",\"url\":\"https:\/\/zappysys.com\/blog\/\",\"name\":\"ZappySys Blog\",\"description\":\"SSIS \/ ODBC Drivers \/ API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/zappysys.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/zappysys.com\/blog\/#\/schema\/person\/2756c237457fbc95d82cb38962f81f82\",\"name\":\"ZappySys\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/zappysys.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5c9be148088ba9b8af8e955c5f7c22b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5c9be148088ba9b8af8e955c5f7c22b5?s=96&d=mm&r=g\",\"caption\":\"ZappySys\"},\"sameAs\":[\"http:\/\/www.zappysys.com\/\",\"https:\/\/www.facebook.com\/ZappySys\/\",\"https:\/\/twitter.com\/https:\/\/twitter.com\/zappysys\/\"],\"url\":\"https:\/\/zappysys.com\/blog\/author\/admin\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using HMAC Authentication for API in SSIS \/ ODBC Drivers | ZappySys Blog","description":"Using HMAC Authentication for API in SSIS \/ ODBC Drivers - ZappySys Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/","og_locale":"en_US","og_type":"article","og_title":"Using HMAC Authentication for API in SSIS \/ ODBC Drivers | ZappySys Blog","og_description":"Using HMAC Authentication for API in SSIS \/ ODBC Drivers - ZappySys Blog","og_url":"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/","og_site_name":"ZappySys Blog","article_author":"https:\/\/www.facebook.com\/ZappySys\/","article_published_time":"2019-04-19T13:49:45+00:00","article_modified_time":"2019-04-22T22:37:52+00:00","og_image":[{"width":856,"height":413,"url":"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-http-connection-hmac-authentication.png","type":"image\/png"}],"author":"ZappySys","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/zappysys\/","twitter_misc":{"Written by":"ZappySys","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/","url":"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/","name":"Using HMAC Authentication for API in SSIS \/ ODBC Drivers | ZappySys Blog","isPartOf":{"@id":"https:\/\/zappysys.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/#primaryimage"},"image":{"@id":"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/#primaryimage"},"thumbnailUrl":"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-http-connection-hmac-authentication.png","datePublished":"2019-04-19T13:49:45+00:00","dateModified":"2019-04-22T22:37:52+00:00","author":{"@id":"https:\/\/zappysys.com\/blog\/#\/schema\/person\/2756c237457fbc95d82cb38962f81f82"},"description":"Using HMAC Authentication for API in SSIS \/ ODBC Drivers - ZappySys Blog","breadcrumb":{"@id":"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/#primaryimage","url":"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-http-connection-hmac-authentication.png","contentUrl":"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/04\/ssis-http-connection-hmac-authentication.png","width":856,"height":413,"caption":"HTTP Connection with HMAC Authentication Option (Azure CosmosDB API Example)"},{"@type":"BreadcrumbList","@id":"https:\/\/zappysys.com\/blog\/using-hmac-authentication-api-ssis-odbc-drivers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/zappysys.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Using HMAC Authentication for API in SSIS \/ ODBC Drivers"}]},{"@type":"WebSite","@id":"https:\/\/zappysys.com\/blog\/#website","url":"https:\/\/zappysys.com\/blog\/","name":"ZappySys Blog","description":"SSIS \/ ODBC Drivers \/ API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/zappysys.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/zappysys.com\/blog\/#\/schema\/person\/2756c237457fbc95d82cb38962f81f82","name":"ZappySys","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/zappysys.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5c9be148088ba9b8af8e955c5f7c22b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5c9be148088ba9b8af8e955c5f7c22b5?s=96&d=mm&r=g","caption":"ZappySys"},"sameAs":["http:\/\/www.zappysys.com\/","https:\/\/www.facebook.com\/ZappySys\/","https:\/\/twitter.com\/https:\/\/twitter.com\/zappysys\/"],"url":"https:\/\/zappysys.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/posts\/6789"}],"collection":[{"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/comments?post=6789"}],"version-history":[{"count":8,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/posts\/6789\/revisions"}],"predecessor-version":[{"id":6849,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/posts\/6789\/revisions\/6849"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/media\/6846"}],"wp:attachment":[{"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/media?parent=6789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/categories?post=6789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/tags?post=6789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}