是否可以使用AWS Lambda请求oauth 2.0令牌? [英] Is it possible to use AWS Lambda to request an oauth 2.0 token?

查看:169
本文介绍了是否可以使用AWS Lambda请求oauth 2.0令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找避免创建ec2 instance的方法,以便具有有效的回调URL来执行oauth握手.

I am looking for ways to avoid creating an ec2 instance in order to have a valid callback URL to perform the oauth handshake.

我计划使用Lambda连接到远程API,但是我需要能够首先获得令牌,该令牌仅可使用6个小时.

I plan to use Lambda to connect to a remote API, but I need to be able to get the token first, which is valid only for 6 hours.

我可以通过Lambda函数进行握手吗?

Is there any way I can make the handshake via Lambda functions?

推荐答案

我认为LambdaAPI Gateway一起提供了一个很好的解决方案. API网关允许您创建一个持久的,可公开访问的HTTP端点.您可以定义将HTTP方法映射到lambda函数调用的特定资源".

I think Lambda along with API Gateway offer a good solution. API Gateway allows you to create a persistent, publicly accessible HTTP endpoint. You can define specific 'resources' that map HTTP methods to lambda function calls.

我对OAuth 2并不是特别熟悉,但是我在想像这样的事情:在API Gateway中,使用调用Lambda函数的GET方法定义资源"/回调".

I'm not especially familiar with OAuth 2, but I'm imagining something like this: In API Gateway, define a resource '/callback' with a GET method that invokes your Lambda function.

将API网关终结点注册为应用程序的回调URI,如下所示:

Register the API Gateway endpoint as your application's callback URI, which would look something like this:

https://c1bql2cdxy.execute-api.us-east -1.amazonaws.com/callback

这样做,远程服务将调用您的lambda函数,该函数然后可以从请求中读取授权令牌并根据需要使用它,无论是否涉及1)将令牌存储在数据库中以备将来使用(和重用)通过其他服务,2)直接调用同一Lambda函数中的服务,等等.

By doing so, the remote service will invoke your lambda function, which can then read the authorization token from the request and use it however needed, whether that involves 1) storing the token in a database for future use (and reuse) by other services, 2) directly invoking the services within the same Lambda function, etc.

这篇关于是否可以使用AWS Lambda请求oauth 2.0令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆