Python Iam在生成JWT json web令牌和发布时出现401错误

Python Iam在生成JWT json web令牌和发布时出现401错误,python,jwt,actions-on-google,service-accounts,google-client,Python,Jwt,Actions On Google,Service Accounts,Google Client,我正在使用google服务帐户密钥生成JWT json web令牌,并试图发布数据,但我得到401错误,这里我使用的是google客户端库 def generate_jwt(): with open("service_account_file.json") as json_file: service_account_file_opened= json.load(json_file) signer = google.auth.crypt.RSASigner

我正在使用google服务帐户密钥生成JWT json web令牌,并试图发布数据,但我得到401错误,这里我使用的是google客户端库

    def generate_jwt():
    with open("service_account_file.json") as json_file:
        service_account_file_opened= json.load(json_file)

    signer = google.auth.crypt.RSASigner.from_service_account_file("service_account_file.json")
    now = int(time.time())
    expires = now + 3600  # One hour in seconds

    payload = {
        'iat': now,
        'exp': expires,
        '**aud**': 'https://www.googleapis.com/auth/actions.fulfillment.conversation',
        '**iss**': 'notifications@eprint-9ff89.iam.gserviceaccount.com',
        '**sub**': 'notifications@eprint-9ff89.iam.gserviceaccount.com',
        'email': 'notifications@eprint-9ff89.iam.gserviceaccount.com'
    }

    jwt = google.auth.jwt.encode(signer, payload)

    return jwt
hed={'Authorization':'Bearer{}.format(generate_jwt())}

url = 'https://actions.googleapis.com/v2/conversations:send'
response = requests.post(url, data=json.dumps(notif), headers=hed)
    print(response)

401告诉我们的唯一一件事是您的授权:承载头被拒绝。你能告诉我们更多细节吗?解决了谢谢是的这是令牌问题