CurtHagenlocher/AmazonS3

Crypto.CreateHmac / Crypto.CreateHash issue

Closed this issue · 1 comments

Hi Curt,

I am working on custom power BI connector, try to set up OAuth 1.0. when I generate Authentication Header for Signature.

I tried to use Crypto.createHmac

            // Construct the data string
            data = "oauth_consumer_key=" & CONSUMER_KEY & "&"&
                    "oauth_nonce=" & OAUTH_NONCE & "&" &
                    "oauth_signature_method=" & SIGN_METHOD & "&" &
                "oauth_timestamp=" & TIME_STAMP & "&" &
                "oauth_token=" & TOKEN_ID & "&" &
                "oauth_version=" & OAUTH_VERSION,

            // Construct the signature value
            signatureValue = HTTP_METHOD & "&" & Uri.EscapeDataString(BASE_URL) & "&" & Uri.EscapeDataString(data),
            // Construct the signature key
            signatureKey = Uri.EscapeDataString(CONSUMER_SECRET) & "&" & Uri.EscapeDataString(TOKEN_SECRET),
            signatureValueB=Text.ToBinary(signatureValue,TextEncoding.Utf8),
            signature = Crypto.createHmac(CryptoAlgorithm.SHA256,signatureKey,signatureValueB),
            auth = data & "&oauth_signature=" & Binary.ToText(signature, BinaryEncoding.Hex)
        in
            auth


but it keeps told me Crypto.createHmac matches no exports, look like it can't found Crypto.createHmac. Do you know if I need to import library or something ?

sloved, due to not missing encode key

        signatureKeyB = Text.ToBinary(signatureKey, TextEncoding.Utf8),

works,
Thx