OAuth Signature

View as MarkdownOpen in Claude

Creating the OAuth Signature is a multi-stage process.

  1. First uses will need to create an HMAC Sha256 hash of the encoded base string
    1. You must use a Base64 byte array of our live session token as the Key value.
  2. Then, hash the encoded byte string using our new HMAC Sha256 object.
  3. Convert the resulting bytes into a Base64 encoded string.
  4. Then URI escape our string, again using Rfc3986, to receive our final oauth_signature value.
1# Generate bytestring HMAC hash of base string bytestring.
2# Hash key is base64-decoded LST bytestring, method is SHA256.
3bytes_hmac_hash = HMAC.new(
4 key=base64.b64decode(live_session_token),
5 msg=base_string.encode("utf-8"),
6 digestmod=SHA256
7 ).digest()
8
9# Generate str from base64-encoded bytestring hash.
10b64_str_hmac_hash = base64.b64encode(bytes_hmac_hash).decode("utf-8")
11
12# URL-encode the base64 hash str and add to oauth params dict.
13oauth_params["oauth_signature"] = quote_plus(b64_str_hmac_hash)