I’m trying to replicate a call to a remote REST API that uses hmac encoding to 
construct an authentication string.  I’m working from existing Python code that 
does the same thing.

What I’m seeing is that the crypto:hmac() function can return Base64 strings 
that include characters that must be escaped in URIs, i.e.:

mTA76dRZkiCf84WUKM/PWySydamj3dMZ6Tm26s9QGNI

(Note the “/”)

Python’s base64 support includes the method urlsafe_b64encode(), which avoids 
the characters “+” and “/”.

Unfortunately the handler of the API call fails if I escape the “/” or “+”—I’m 
not sure why.

So I need to construct the same URI-friendly base64 string that the Python 
method is generating.

I don’t see an obvious way to do this with the BaseX conversion package.

Is there a way short of implementing my own Base64 encoding algorithm to get a 
URI-friendly base64 string?

I’m using  9.6.4 at the moment but could upgrade if necessary.

Thanks,

E.
_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> | 
Twitter<https://twitter.com/servicenow> | 
YouTube<https://www.youtube.com/user/servicenowinc> | 
Facebook<https://www.facebook.com/servicenow>

Reply via email to