首页 > 解决方案 > 使用 aws cli 命令在 AWS Cognito 中操作回调 URL

问题描述

我想在我的aws cognito使用aws cli命令(来自 shell 脚本)中修改现有的回调 url。

下面的命令我用来描述用户池客户端。

aws cognito-idp describe-user-pool-client --user-pool-id us-west-2_asASD24d --client-id asdfasdf546a5s4df --region us-west-2

现在我想检查我的 url 在回调 url 中是否可用。如果没有,则将此 url 添加到回调 url 中。

我可以使用以下命令来实现这一点。

aws cognito-idp describe-user-pool-client --user-pool-id us-west-2_asASD24d --client-id asdfasdf546a5s4df --region us-west-2 --callback-urls <value>

但我不知道如何在 shell 脚本中操作现有的回调 url。

并且应该在更新用户池客户端时给出每个参数?

我尝试使用以下命令更新回调 URL,并且我剩余的所有设置都被删除。

aws cognito-idp update-user-pool-client --user-pool-id us-west-2_peANXssz7 --client-id 22d80r9fh1oh80i5pc5vuc63br --region us-west-2 --callback-urls '["https://test-jdtest.dev.com?oauth=callback",]'

有什么帮助吗?

标签: shellaws-cliaws-cognitoaws-userpools

解决方案


这个有效。

ExistingCallbackUrls=$(aws cognito-idp describe-user-pool-client --user-pool-id $CognitoPoolId --client-id $CognitoClientId --region $AWS_REGION --output text | grep CALLBACKURLS | awk '{print $2}')

YourUrl=https://example.com

NewCallbackUrls="$ExistingCallbackUrls $YourUrl"

aws cognito-idp update-user-pool-client --user-pool-id $CognitoPoolId --client-id $CognitoClientId --callback-urls $NewCallbackUrls --region $AWS_REGION

推荐阅读