[英]Python Authorizer with API Gateway
我正在嘗試使用有效負載格式 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'
知道我做錯了什么嗎?
您將其作為字符串返回,它甚至不是有效的 JSON。
您可以嘗試:
response = {"isAuthorized":True}
y = json.dumps(response)
或者
y = {"isAuthorized":True}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.