Skip to content

Instantly share code, notes, and snippets.

@panreel
Created May 9, 2022 16:57
Show Gist options
  • Save panreel/df0d7a6c8d892291cc255ae2283a6fa4 to your computer and use it in GitHub Desktop.
Save panreel/df0d7a6c8d892291cc255ae2283a6fa4 to your computer and use it in GitHub Desktop.
Python code to generate appsecret_proof and appsecret_time need to call Workplace API with appsecret_proof configured: https://developers.facebook.com/docs/workplace/reference/permissions/#appsecretproof
import hmac
import hashlib
import time
access_token = 'access_token'
app_secret = 'app_secret'
time = int(time.time())
hmac_secret = app_secret.encode()
hmac_data = (access_token+'|'+str(time)).encode()
app_secret_proof=hmac.new(hmac_secret,hmac_data,hashlib.sha256).hexdigest()
print('Time:', time)
print('Data:', hmac_data)
print('Secret:', hmac_secret)
print('App Secret Proof:', app_secret_proof)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment