Confused about signing JWT

You need to cast user_id to a string

payload = {
    'exp': math.floor(time.time())+(60*60),
    'user_id': str(61960862),
    'role' : 'external'
};

Should work for python