Skip to content

Instantly share code, notes, and snippets.

@panreel
panreel / appsecretproof.py
Created May 9, 2022 16:57
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)