NEW: Signed Authentication Builder (Hash Helper) (advanced)

Some third-party APIs, such as Amazon Web Services and Moz, require a signed authentication parameter to be included in their API query to secure the identity of the user making the API query. A signed authentication parameter is comprised of one or more data elements, such as an API key or a user ID, that have been encrypted to produce a unique key. Klipfolio's Signed Authentication Builder (Hash Helper) provides a set of methods to create this signed authentication parameter. The data elements required to build the signed authentication parameter are specified by the third-party API.

Signed Authentication Parameter

The signed authentication parameter is included in the API query as a regular parameter and is built using the Signed Authentication Builder methods, which must be placed in a specific order:

  1. Append the sub-parameters required to create the signed authentication parameter.
  2. Specify the encrypt method to apply to the signed authentication parameter.
  3. Specify the encode method to apply to the signed authentication parameter.
  4. Apply the print method to return the text representation of the signed authentication parameter.

The following shows an example of an API query with a signed authentication parameter (in yellow) encoded. Note that the value assigned to the signed authentication parameter must end in a semi-colon and be wrapped in curly braces.

https://api.sample.com/version/endpoint?parameter=value &signedAuthentication={hash.appendMethods(dataElement).encryptMethods.encodeMethods.printDigest();}

Expiry Parameter

An expiry parameter is often required with signed authentication to provide additional security by limiting the length of time an API query is valid. The expiry parameter value is generated using the getExpiryTime() method. The following shows an example of an API query with an expiry parameter, expiryTime, set to 300 seconds from the time the query is sent. Note the method is suffixed with a semi-colon and wrapped in curly braces.

https://api.sample.com/version/endpoint?parameter=value&expiryTime={hash.getExpiryTime(300);}

Methods

Signed Authentication Builder methods can be applied iteratively, or “chained”, as needed to meet the signed authentication requirements for a given API.

Append Methods

The append methods are used to build the signed authentication parameter using the data elements specified by the third-party API.

append("data") Append a data element (in quotation marks) to the signed authentication parameter. For example,
hash.append("mozscape-a1b2c3d4e5")

append(hash.getExpiryTime(secondsFromRequest)) Append the Epoch time that is secondsFromRequest in the future from the time the method is executed. For example,
hash.append(hash.getExpiryTime(240))

appendNewLine() Append a newline character to the signed authentication parameter. For example,
hash.append("beforeNewLine").appendNewLine().append("afterNewLine")

Encrypt Methods

encodeMd5() Convert the signed authentication parameter to a 16-byte MD5-encoded value. This is typically represented by a 32-digit hexadecimal number which can be retrieved using the toHex() method.

encodeSha1() Convert the signed authentication parameter to a 20-byte SHA1-encoded value. This is typically represented by a 40-digit hexadecimal number which can be retrieved using the toHex() method.

encodeHmacSha1 ("secretKey") Convert the signed authentication parameter to a HmacSha1-encoded value. This requires a secretKey which, if required by the API, is provided with the API credentials.

encodeHmacSha256 ("secretKey") Convert the signed authentication parameter to a HmacSha256-encoded value. This requires a secretKey which, if required by the API, is provided with the API credentials.

The following encode methods convert the signed authentication parameter to the required output format.

encodeBase64() Convert the signed authentication parameter to Base64 encoding.

encodeURL() Convert the signed authentication parameter to UTF-8 URL encoding.

toHex() Convert a 16-byte MD5 or 20-byte SHA1 signed authentication parameter to 32-digit and 40-digit hexadecimal numbers (2 digits per byte).

Print Method

printDigest() Get the text representation of the encoded signed authentication parameter. This method must be the last method in the chain and is followed by a semi-colon.

How to build a signed authentication parameter

Each incremental step of the API query has a yellow background.

  1. Create the API query as required. In this example, only one parameter, parameter1, (aside from the signed authentication parameter) will be passed to the ExampleOnly API.

    https://api.ExampleOnly.com/v1/data?parameter1=value1


  2. Append the data elements to be encrypted and encoded using sequences of hash.append() contained within curly braces. This signature requires an expiry time as well as an Access ID (0123456789) and Key (a1b2c3d4e5f6).

    https://api.ExampleOnly.com/v1/data?parameter1=value1&signedAuthentication={hash.append(hash.getExpiryTime(300)).append("0123456789").append("a1b2c3d4e5f6")}


  3. Apply the encode algorithms as required by the API. In this case, the ExampleOnly API requires MD5 encoding.

    https://api.ExampleOnly.com/v1/data?parameter1=value1&signedAuthentication={hash.append(hash.getExpiryTime(240)).append("0123456789").append("a1b2c3d4e5f6").encodeMd5().toHex()}


  4. Apply the printDigest() method to obtain the text representation of the signed authentication parameter to be used in the API query.

    https://api.ExampleOnly.com/v1/data?parameter1=value1&signedAuthentication={hash.append(hash.getExpiryTime(240)).append("0123456789").append("a1b2c3d4e5f6").encodeMd5().toHex().printDigest();}

Example API queries with signed authentication parameters

The following examples use Signed Authentication Builder methods (in green text) to create the signed authentication parameters required by these APIs.

Moz

http://lsapi.seomoz.com/linkscape/url-metrics/moz.com%2fblog?Cols=4&AccessID=mozscape-b6838361ee&Expires={hash.getExpiryTime(240);}&signedAuthentication={hash.append("mozscape-a1b2c3d4e5").appendNewLine().append(hash.getExpiryTime(240)).encodeHmacSha1("0123456789abcdef0123456789abcdef").encodeBase64().encodeURL().printDigest();}

Marvel:

http://gateway.marvel.com/v1/public/characters?ts={hash.getExpiryTime(300);}&apikey=91e13b2be07839c935d336286e1b8c45&hash={hash.append(hash.getExpiryTime(240)).append("d636a3ceceee7cfbce702595820b020d17d67fc5").append("91e13b2be07839c935d336286e1b8c45").encodeMd5().toHex().printDigest();}

Related Articles

Connecting to data sources

  1. Klipfolio Data Source Integrations
  2. Creating data sources
  3. Best practices for uploading your data
  4. Updating data sources
  5. About data source refresh
  6. Install the latest Google Analytics KlipStart Dashboard
  7. NEW: Install the latest Google AdWords KlipStart (for MCC accounts only)
  8. Guide to Web Accessible (REST API) data sources
  9. Authentication method: OAuth Token Authentication for Web Accessible Data Source
  10. Why does Klipfolio need specific permissions to connect my service accounts?
  11. Authentication method: 2 Step Authentication
  12. Authentication method: Basic HTTP Authentication
  13. Authentication method: API Key Authentication
  14. Managing OAuth tokens for connected accounts
  15. Use date range parameters to modify data retrieval period
  16. NEW: Signed Authentication Builder (Hash Helper) (advanced)
  17. Locate a data source ID
  18. SQL Databases
  19. Use files from your computer as a data source
  20. Use Email Attachments as a data source
  21. Use Excel spreadsheets as a data source
  22. NEW: Use Adobe Analytics as a data source
  23. NEW: Use Alexa as a data source
  24. Use Asana as a data source
  25. NEW: Use Atlassian JIRA as a data source
  26. NEW: Use AWeber as a Data Source
  27. NEW: Use Basecamp as a data source
  28. Use Bitly as a data source
  29. Use Box as a data source
  30. NEW: Use Buffer as a data source
  31. NEW: Use CallRail as a data source
  32. Use Campaign Monitor as a data source
  33. NEW: Use Chargify as a data source
  34. Use Cloud Monitor as a data source
  35. Use comScore Digital Analytix as a data source
  36. NEW: Use Desk.com as a data source
  37. Use Dropbox as a data source
  38. Use Eloqua as a data source
  39. Use Facebook as a data source
  40. NEW: Use Facebook Ads as a data source
  41. NEW: Use FluidSurveys as a data source
  42. Use Freshdesk as a data source
  43. NEW: Use Fusebill as a data source
  44. Use FTP or SFTP as a data source
  45. NEW: Use Glassdoor as a data source
  46. Use Google+ as a data source
  47. NEW: Use Google AdWords as a data source
  48. Use Google Analytics as a data source
  49. Use Google Analytics to create a Multi-Channel Funnel (MCF) API data source
  50. NEW: Use Google Calendar as a data source
  51. Use Google Drive Apps as a data source
  52. Use Google Webmaster Tools as a data source
  53. NEW: Use Harvest as a Data Source
  54. NEW: Use GoSquared as a data source
  55. Use Heartbeat as a Data Source
  56. NEW: Use HubSpot as a data source
  57. NEW: Use iFormBuilder as a data source
  58. PREVIOUS: Use iFormBuilder as a data source
  59. Use Infusionsoft as a data source
  60. NEW: Use Insightly as a data source
  61. NEW: Use Instagram as a data source
  62. NEW: Use Intercom as a data source
  63. Use Intervals as a data source
  64. NEW: Use Lighthouse as a Data Source
  65. Use LinkedIn as a data source
  66. Use Localytics as a data source
  67. Use MailChimp as a data source
  68. NEW: Use Mixpanel as a data source
  69. NEW: Use Marketo as a data source
  70. NEW: Use Moz as a data source
  71. NEW: Use New Relic as a data source
  72. Use Nicereply as a data source
  73. Use Optimizely as a data source
  74. NEW: Use Pardot as a data source
  75. Use Pingdom as a data source
  76. NEW: Use Pipedrive as a data source
  77. Use Podio as a data source
  78. NEW: Use QuickBooks as a data source
  79. Use QuickBooks with the Email Attachment Connector
  80. NEW: Use Quintly as a data source
  81. Use Radian6 as a data source
  82. NEW: Use RSS news feeds as a data source
  83. Use Salesforce as a data source
  84. Use Searchmetrics as a data source
  85. Use Sendible as a data source
  86. NEW: Use Shopify as a data source
  87. Use ShoreTelSky as a data source
  88. NEW: Use Slack as a data source
  89. Use Smartsheet as a data source
  90. NEW: Use Stripe as a data source
  91. Use SurveyGizmo as a data source
  92. NEW: Use Swrve as a data source
  93. Use Toggl as a data source
  94. NEW: Use Trello as a data source
  95. NEW: Use Taleo as a data source
  96. NEW: Use Talkwalker as a data source
  97. NEW: Use Todoist as a data source
  98. Use Topsy as a data source
  99. Use Twitter as a data source
  100. Use UserVoice as a data source
  101. NEW: Use VKontakte as a data source
  102. Use Webtrends as a data source
  103. NEW: Use Xero as a data source
  104. Use XMLA as a data source
  105. NEW: Use Yahoo Finance as a data source
  106. Use YouTube Analytics as a data source
  107. Use Zendesk as a data source
  108. Use Zoho CRM as a data source
  109. Automate data upload using the data source API
  110. Use Unbounce as a data source
  111. Data examples

Feedback and Knowledge Base