简体   繁体   English

如何将 AWS Lambda function 列入 Google API 的白名单

[英]How to whitelist AWS Lambda function for Google API

I'm building an AWS Lambda function that pulls info from the Google Calendar API using Node.js. The Node application then sends an html response to a third party application.我正在构建一个 AWS Lambda function,它使用 Node.js 从 Google 日历 API 中提取信息。Node 应用程序然后向第三方应用程序发送 html 响应。 I'm basically following this guide from google , except I'm sending the html somewhere else to be rendered.我基本上是在遵循google 的本指南,除了我将 html 发送到其他地方进行渲染。 I keep running into an error where Google tells me I haven't whitelisted the javascript origin coming from Lambda. Here's the error text:我一直遇到错误,Google 告诉我我没有将来自 Lambda 的 javascript 来源列入白名单。这是错误文本:

{error: "idpiframe_initialization_failed", details: ""Not a valid origin for the client: https://<Lambda URL>.execute-api.us-west-2.amazonaws.com has not been whitelisted for client ID <My_Google_API_Client_Id>.apps.googleusercontent.com. Please go to https://console.developers.google.com/ and whitelist this origin for your project's client ID."}

I've gone into the Google API developer console and whitelisted that URL, but I'm still getting that error.我已经进入 Google API 开发者控制台并将 URL 列入白名单,但我仍然收到该错误。 Here's a screenshot.这是一个截图。

I've tried whitelisting "us-west-2.amazonaws.com" as well with no luck.我也试过将“us-west-2.amazonaws.com”列入白名单,但没有成功。 Thanks!!谢谢!!

You'll need to whitelist Lambda's IP addresses, you can't whitelist based on domain name. 您需要将Lambda的IP地址列入白名单,不能基于域名将白名单列入白名单。 You can view the current list of IP addresses here: https://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html 您可以在此处查看当前的IP地址列表: https//docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html

You note your request is coming from us-west-2 so you could whitelist the IPs from that region only by looking for entries matching that region. 您注意到您的请求来自us-west-2因此您只能通过查找与该区域匹配的条目将该区域的IP列入白名单。 122 by my count so thats a pretty big job! 据我所知,122这是一个相当大的工作!

Otherwise, you could look at setting up a NAT within a VPC and using a IP against that to whitelist that sole IP? 否则,您可以考虑在VPC中设置NAT并使用IP来对该白名单进行白名单?

White list AWS Lambda functions' su.net NAT gateway elastic IP address.白名单 AWS Lambda 函数的 su.net NAT 网关弹性 IP 地址。 Follow the article .按照文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM