<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Making a api call to google maps using HMAC-SHA1 signed key in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Making-a-api-call-to-google-maps-using-HMAC-SHA1-signed-key/m-p/435185#M108077</link>
    <description>&lt;P&gt;I am trying to make an api call to google maps using a&amp;nbsp;&lt;SPAN&gt;HMAC-SHA1 signed key. I have to follow these steps.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;Construct the request URL without the signature, making sure to include your&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;client&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;parameter. Note that any non-standard characters will need to be&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://en.wikipedia.org/wiki/Percent-encoding" target="_blank"&gt;URL-encoded&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;A href="https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&amp;amp;destination=Montreal&amp;amp;client=" target="_blank"&gt;https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&amp;amp;destination=Montreal&amp;amp;client=&lt;/A&gt;clientID&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Note: All Google services require UTF-8 character encoding (which implicitly includes ASCII). If your applications operate using other character sets, make sure they construct URLs using UTF-8 and properly URL-encode them.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Strip off the domain portion of the request, leaving only the path and the query:&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;/maps/api/directions/json?origin=Toronto&amp;amp;destination=Montreal&amp;amp;client=clientID&lt;/CODE&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Retrieve your&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.google.com/maps/documentation/directions/get-api-key#cryptographic_signing_keys" target="_blank"&gt;private key&lt;/A&gt;, which is encoded in a modified&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://en.wikipedia.org/wiki/Base64" target="_blank"&gt;Base64&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;for URLs, and sign the URL above using the HMAC-SHA1 algorithm. You may need to decode this key into its original binary format. Note that in most cryptographic libraries, the resulting signature will be in binary format.&lt;/P&gt;&lt;P&gt;Note: Modified Base64 for URLs replaces the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;+&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;/&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;characters of standard Base64 with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;-&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;_&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;respectively, so that these Base64 signatures no longer need to be URL-encoded.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Encode the resulting binary signature using the modified&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://en.wikipedia.org/wiki/Base64" target="_blank"&gt;Base64&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;for URLs to convert this signature into something that can be passed within a URL.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Attach this signature to the URL within a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;signature&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;parameter:&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;A href="https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&amp;amp;destination=Montreal&amp;amp;client=" target="_blank"&gt;https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&amp;amp;destination=Montreal&amp;amp;client=&lt;/A&gt;clientID&amp;amp;signature=base64signature&lt;/CODE&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;CODE&gt;I found this code online, which i thought would help. But it seems to give the wrong result. I have used test case from googles website. The key suppose to be&amp;nbsp;chaRF2hTJKOScPr-RQCEhZbSzIE=, but the key returned is&amp;nbsp;MqYEMSmWU6nGbkqbN8DBP6PQC2o=&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let key = %nrstr(vNIXE0xscrmjlyV-12Nj_BvUPaw=);
%let message = %sysfunc(urlencode(%nrstr(https://maps.googleapis.com/maps/api/geocode/json?address=New+York&amp;amp;client=clientID)));
 
proc groovy;

add sasjar="commons_codec" version="1.7.0.0_SAS_20121211183158"; *version is specific to SAS Installation and may differ from this;

submit "&amp;amp;key." "&amp;amp;message.";
 
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
import org.apache.commons.codec.binary.Base64
 
def base64hmacsha1(key, message) {
    mac = Mac.getInstance("HmacSHA1")
    mac.init(new SecretKeySpec(key.getBytes(), "HmacSHA1"))
 
    sha1_bytes = mac.doFinal(message.getBytes())
 
    base64 = new Base64()
    return new String(base64.encode(sha1_bytes))
}
 
exports.base64hmacsha1 = base64hmacsha1(args[0], args[1])
 
endsubmit;
 
quit;
%put &amp;amp;base64hmacsha1.;
/*chaRF2hTJKOScPr-RQCEhZbSzIE=*/&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Feb 2018 08:24:34 GMT</pubDate>
    <dc:creator>rudfaden</dc:creator>
    <dc:date>2018-02-08T08:24:34Z</dc:date>
    <item>
      <title>Making a api call to google maps using HMAC-SHA1 signed key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Making-a-api-call-to-google-maps-using-HMAC-SHA1-signed-key/m-p/435185#M108077</link>
      <description>&lt;P&gt;I am trying to make an api call to google maps using a&amp;nbsp;&lt;SPAN&gt;HMAC-SHA1 signed key. I have to follow these steps.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;Construct the request URL without the signature, making sure to include your&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;client&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;parameter. Note that any non-standard characters will need to be&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://en.wikipedia.org/wiki/Percent-encoding" target="_blank"&gt;URL-encoded&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;A href="https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&amp;amp;destination=Montreal&amp;amp;client=" target="_blank"&gt;https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&amp;amp;destination=Montreal&amp;amp;client=&lt;/A&gt;clientID&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Note: All Google services require UTF-8 character encoding (which implicitly includes ASCII). If your applications operate using other character sets, make sure they construct URLs using UTF-8 and properly URL-encode them.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Strip off the domain portion of the request, leaving only the path and the query:&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;/maps/api/directions/json?origin=Toronto&amp;amp;destination=Montreal&amp;amp;client=clientID&lt;/CODE&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Retrieve your&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.google.com/maps/documentation/directions/get-api-key#cryptographic_signing_keys" target="_blank"&gt;private key&lt;/A&gt;, which is encoded in a modified&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://en.wikipedia.org/wiki/Base64" target="_blank"&gt;Base64&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;for URLs, and sign the URL above using the HMAC-SHA1 algorithm. You may need to decode this key into its original binary format. Note that in most cryptographic libraries, the resulting signature will be in binary format.&lt;/P&gt;&lt;P&gt;Note: Modified Base64 for URLs replaces the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;+&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;/&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;characters of standard Base64 with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;-&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;_&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;respectively, so that these Base64 signatures no longer need to be URL-encoded.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Encode the resulting binary signature using the modified&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://en.wikipedia.org/wiki/Base64" target="_blank"&gt;Base64&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;for URLs to convert this signature into something that can be passed within a URL.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Attach this signature to the URL within a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;signature&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;parameter:&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;A href="https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&amp;amp;destination=Montreal&amp;amp;client=" target="_blank"&gt;https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&amp;amp;destination=Montreal&amp;amp;client=&lt;/A&gt;clientID&amp;amp;signature=base64signature&lt;/CODE&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;CODE&gt;I found this code online, which i thought would help. But it seems to give the wrong result. I have used test case from googles website. The key suppose to be&amp;nbsp;chaRF2hTJKOScPr-RQCEhZbSzIE=, but the key returned is&amp;nbsp;MqYEMSmWU6nGbkqbN8DBP6PQC2o=&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let key = %nrstr(vNIXE0xscrmjlyV-12Nj_BvUPaw=);
%let message = %sysfunc(urlencode(%nrstr(https://maps.googleapis.com/maps/api/geocode/json?address=New+York&amp;amp;client=clientID)));
 
proc groovy;

add sasjar="commons_codec" version="1.7.0.0_SAS_20121211183158"; *version is specific to SAS Installation and may differ from this;

submit "&amp;amp;key." "&amp;amp;message.";
 
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
import org.apache.commons.codec.binary.Base64
 
def base64hmacsha1(key, message) {
    mac = Mac.getInstance("HmacSHA1")
    mac.init(new SecretKeySpec(key.getBytes(), "HmacSHA1"))
 
    sha1_bytes = mac.doFinal(message.getBytes())
 
    base64 = new Base64()
    return new String(base64.encode(sha1_bytes))
}
 
exports.base64hmacsha1 = base64hmacsha1(args[0], args[1])
 
endsubmit;
 
quit;
%put &amp;amp;base64hmacsha1.;
/*chaRF2hTJKOScPr-RQCEhZbSzIE=*/&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 08:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Making-a-api-call-to-google-maps-using-HMAC-SHA1-signed-key/m-p/435185#M108077</guid>
      <dc:creator>rudfaden</dc:creator>
      <dc:date>2018-02-08T08:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Making a api call to google maps using HMAC-SHA1 signed key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Making-a-api-call-to-google-maps-using-HMAC-SHA1-signed-key/m-p/435399#M108181</link>
      <description>&lt;P&gt;Not avoiding your original question, but depending on what you're trying to do with Google Maps, &lt;A href="https://blogs.sas.com/content/tag/google-maps/" target="_self"&gt;this series of articles&lt;/A&gt;&amp;nbsp;about Google Maps with SAS from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/51532"&gt;@LeonidBatkhan&lt;/a&gt;&amp;nbsp;might help.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 19:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Making-a-api-call-to-google-maps-using-HMAC-SHA1-signed-key/m-p/435399#M108181</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-02-08T19:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Making a api call to google maps using HMAC-SHA1 signed key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Making-a-api-call-to-google-maps-using-HMAC-SHA1-signed-key/m-p/435528#M108211</link>
      <description>I am trying to use a Google premium account for google maps, as I need to use Google maps beyond with is available free</description>
      <pubDate>Fri, 09 Feb 2018 06:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Making-a-api-call-to-google-maps-using-HMAC-SHA1-signed-key/m-p/435528#M108211</guid>
      <dc:creator>rudfaden</dc:creator>
      <dc:date>2018-02-09T06:26:43Z</dc:date>
    </item>
  </channel>
</rss>

