How to use SHA256-HMAC in python code?
<p><a href="https://doc.periscopedata.com/doc/embed-api" rel="nofollow">I am taking message and key from this URL</a></p>

<pre><code>import hmac
import hashlib
import base64
my = "/api/embedded_dashboard?data=%7B%22dashboard%22%3A7863%2C%22embed%22%3A%22v2%22%2C%22filters%22%3A%5B%7B%22name%22%3A%22Filter1%22%2C%22value%22%3A%22value1%22%7D%2C%7B%22name%22%3A%22Filter2%22%2C%22value%22%3A%221234%22%7D%5D%7D"
key = "e179017a-62b0-4996-8a38-e91aa9f1"
print(hashlib.sha256(my + key).hexdigest())
</code></pre>

<p>I am getting this result:</p>

<pre><code>2df1d58a56198b2a9267a9955c31291cd454bdb3089a7c42f5d439bbacfb3b88
</code></pre>

<p>Expecting result:</p>

<pre><code>adcb671e8e24572464c31e8f9ffc5f638ab302a0b673f72554d3cff96a692740
</code></pre>

<p>You are not making use of <code>hmac</code> at all in your code. </p>

<p>Typical way to use <code>hmac</code>, construct an HMAC object from your key, message and identify the hashing algorithm by passing in its constructor:</p>

<pre><code>h = hmac.new( key, my, hashlib.sha256 )
print( h.hexdigest() )
</code></pre>

<p>That should output </p>

<pre><code>adcb671e8e24572464c31e8f9ffc5f638ab302a0b673f72554d3cff96a692740
</code></pre>

<p>for your example data.</p>

python oauth sha256 hmac