iOS - 亚马逊Cognito + Kinesis视频作为嘉宾用户。

问题描述 投票:1回答:1

TLDR: 如何使用Amazon服务与客人未认证的用户?

我一直在尝试用客人用户实现Amazon Kinesis视频流,但无济于事。下面是我所做的或得到的,到目前为止。

  1. 按照这个 联系 并有一个项目可以使用用户池和身份池设置。
  2. 在我的身份池中启用了本文档中所说的非认证访问。联系.
  3. 我已经过了 获取证书 doc 但我不认为我完全理解我需要做什么。我已经按照我的理解进行了尝试,但没有成功(将代码贴在下面)。
  4. 使用策略模拟器验证了与身份池相关联的角色(Auth和UnAuth)是否具有该工作的权限(两个角色具有相同的权限)。

现在的问题是,它可以完美地与亚马逊认知认证用户一起工作,但不能为客人用户工作。我的代码库是上面第一个链接中亚马逊提供的示例项目。为了尝试客人用户,我只是跳过登录页面,直接登陆频道页面,在 样板应用. 在那里,我只是调用 createSignalingChanneldescribeSignalingChannel 关于 AWSKinesisVideo 并在XCode中得到以下错误。

Error Domain=com.amazonaws.AWSKinesisVideoErrorDomain Code=1 "null" UserInfo={NSLocalizedDescription=null, NSLocalizedFailureReason=AccessDeniedException:http://internal.amazon.com/coral/com.amazon.coral.service/}

我已经找了好几天了,我在文档中找到的唯一信息是,它是可能的,但不知道怎么做。我认为唯一缺少的步骤是连接应用程序或以访客用户身份访问服务或.Console等配置都设置好了。

为Kinesis视频流分享创建频道的代码。

    let credentialsProvider = AWSCognitoCredentialsProvider(regionType: .USEast2, identityPoolId: cognitoIdentityPoolId)
    let configuration = AWSServiceConfiguration(region: .USEast2, credentialsProvider: credentialsProvider)

    AWSServiceManager.default().defaultServiceConfiguration = configuration
    credentialsProvider.getIdentityId().continueWith(block: { (task) -> AnyObject? in
        if (task.error != nil) {
            print("Error: " + task.error!.localizedDescription)
        }
        else {
            // the task result will contain the identity id
            // let cognitoId = task.result!
            // I don't know what to do here or what to do with this Id, this code block is here
            // because it was part of getting credentials link. I have tried without it as well
        }

        return task;

    })

    //        let configuration = AWSServiceConfiguration(region: self.awsRegionType, credentialsProvider: AWSMobileClient.default())
    AWSKinesisVideo.register(with: configuration!, forKey: awsKinesisVideoKey) // "kinesisvideo" 

    self.retrieveChannelARN(channelName: channelNameValue)
    if self.channelARN == nil {
        self.createChannel(channelName: channelNameValue)
    }

retrieveChannelARNcreateChannel 方法没有变化,它们是 示例代码,如下所示。

func createChannel(channelName: String) {
    let kvsClient = AWSKinesisVideo(forKey: awsKinesisVideoKey)
    let createSigalingChannelInput = AWSKinesisVideoCreateSignalingChannelInput.init()
    createSigalingChannelInput?.channelName = channelName
    kvsClient.createSignalingChannel(createSigalingChannelInput!).continueWith(block: { (task) -> Void in
        if let error = task.error {
            print("Error creating channel \(error)")
            return
        } else {
            self.channelARN = task.result?.channelARN
            print("Channel ARN : ", task.result?.channelARN)
        }
    }).waitUntilFinished()
    if (self.channelARN == nil) {
        let alertController = UIAlertController(title: "Unable to create channel",
                                                message: "Please validate all the input fields",
                                                preferredStyle: .alert)
        let okAction = UIAlertAction(title: "Ok", style: .default, handler: nil)
        alertController.addAction(okAction)

        self.present(alertController, animated: true, completion: nil)
        return
    }
}

func retrieveChannelARN(channelName: String) {
    if !channelName.isEmpty {
        let describeInput = AWSKinesisVideoDescribeSignalingChannelInput()
        describeInput?.channelName = channelName
        let kvsClient = AWSKinesisVideo(forKey: awsKinesisVideoKey)
        kvsClient.describeSignalingChannel(describeInput!).continueWith(block: { (task) -> Void in
            if let error = task.error {
                print("Error describing channel: \(error)")
            } else {
                self.channelARN = task.result?.channelInfo?.channelARN
                print("Channel ARN : ", task.result!.channelInfo!.channelARN ?? "Channel ARN empty.")
            }
        }).waitUntilFinished()
    } else {
        let alertController = UIAlertController(title: "Channel Name is Empty",
                                                message: "Valid Channel Name is required.",
                                                preferredStyle: .alert)
        let okAction = UIAlertAction(title: "Ok", style: .default, handler: nil)
        alertController.addAction(okAction)
        present(alertController, animated: true, completion: nil)
        return
    }
}

我还注意到 internalCredentials 的财产 credentialsProvider 在认证用户中存在,但在访客用户中不存在,我只是不知道如何补救。任何帮助将被感激。谢谢你的帮助

身份池设置

UnAuthRole

AuthRole

ios swift amazon-cognito amazon amazon-kinesis
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.