我正在嘗試使用有效負載格式 2.0 制作一個自定義 python 授權方,現在我保持它非常簡單,并且只回傳 json“{isAuthorized:true}”,無論呈現什么令牌。
但是,我仍然在 cloudwatch 中遇到失敗,說格式不正確..
我也嘗試過將“isAuthorized”作為簡單的回應。
我正在使用簡單回應模式。
這是簡單的python授權器:
import os
import re
import json
import logging
import base64
import boto3
def lambda_handler(event, context):
try:
response = "{isAuthorized:True}"
y = json.dumps(response)
return y;
except:
return "";
我也試過沒有這樣的 json.dumps:
...
try:
response = {"isAuthorized": True}
return response;
...
這是 CloudWatch 中的錯誤:
The response from the Lambda Authorizer function doesn't match the format that API Gateway expects. Simple response did not include 'isAuthorized'
知道我做錯了什么嗎?
uj5u.com熱心網友回復:
您將其作為字串回傳,這甚至不是有效的 JSON。
您可以嘗試:
response = {"isAuthorized":True}
y = json.dumps(response)
或者
y = {"isAuthorized":True}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/513381.html
上一篇:軟邊緣圓形影像
