def calculate_at_hash(access_token, hash_alg):
 hash_digest = hash_alg(access_token.encode('utf-8')).digest()
 cut_at = int((len(hash_digest) / 2))
 truncated = hash_digest[:cut_at]
 from jwt.utils import base64url_encode
 at_hash = base64url_encode(truncated)
 return at_hash.decode('utf-8')

def calculate_at_hash ( access_token , hash_alg ) : hash_digest = hash_alg ( access_token . encode ( 'utf-8' ) ) . digest ( ) cut_at = int ( ( len ( hash_digest ) / 2 ) ) truncated = hash_digest [ : cut_at ] from jwt . utils import base64url_encode at_hash = base64url_encode ( truncated ) return at_hash . decode ( 'utf-8' )
helper method for calculating an access token hash .