

# 在 IVS 通道上启用播放授权
<a name="private-channels-enable-playback-auth"></a>

频道的授权要求可以在创建通道时或稍后（使用更新操作）进行配置。请注意，无论您要启用还是禁用播放授权，步骤都是相同的。

请注意，播放限制策略（例如地理屏蔽）不能与播放授权同时使用。如果为某个频道启用了播放授权，则配置的任何播放限制策略都将被忽略。要对私有频道实施地理限制，请在发布播放令牌之前验证用户在令牌生成逻辑中的位置。

## 控制台说明
<a name="private-channels-auth-console"></a>

要在创建通道时启用授权，请执行以下操作：

1. 打开 [Amazon IVS 控制台](https://console.aws.amazon.com/ivs)。如果您尚未选择通道所在的区域，请选择区域。

1. 在 **Get started (开始使用)** 框（右上角）中，选择 **Create channel (创建通道)**。

1. 在 **Create channel (创建通道)** 页面上，选择 **Custom configuration (自定义配置)**。

1. 在 **Playback authentication (播放身份验证)** 部分，启用 **Enable token-authentication requirement for video playback (启用视频播放令牌身份验证要求)**。

1. 请按照接下来的提示来创建通道。（请参阅 [IVS 低延迟流式传输入门](getting-started.md)。）

要通过更新现有通道启用授权，请执行以下操作：

1. 打开 [Amazon IVS 控制台](https://console.aws.amazon.com/ivs)。如果您尚未选择通道所在的区域，请选择区域。

1. 在左侧导航菜单中，选择 **Channels (通道)**。

1. 选中要更新的通道的复选框，然后选择 **Edit (编辑)**。

1. 在 **Playback authentication (播放身份验证)** 部分，启用 **Enable token-authentication requirement for video playback (启用视频播放令牌身份验证要求)**。

1. 单击 **Save Changes (保存更改)**。

## CLI 说明
<a name="private-channels-auth-cli"></a>

要在创建通道时启用授权，请执行以下操作：

```
aws ivs create-channel --authorized --region <aws-region>
```

如果区域位于您的本地亚马逊云科技配置文件中，您可以忽略 `--region <aws-region>`。

以下是响应示例。请注意，`authorized` 为 `true` 。

```
{
    "streamKey": {
        "channelArn": "arn:aws:ivs:us-west-2:123456789:channel/fbc789c1-2c56-4ce6-a30a-d99275dc4481",
        "value": "sk_us-west-2_abcd1234efgh5678ijkl",
        "arn": "arn:aws:ivs:us-west-2:123456789:stream-key/62f15f1b-fe31-4127-b252-0666ac7f55a7",
        "tags": {}
    },
    "channel": {
        "name": "test-channel",
        "tags": {},
        "authorized": true,
        "latencyMode": "LOW",
        "ingestEndpoint": "jds34ksdg3las.global-contribute.live-video.net",
        "playbackUrl": "https://b37c565f6d79.us-west-2.playback.live-video.net/api/video/v1/aws.ivs.us-west-2.123456789.channel.oU4OKS4LA1Dz.m3u8",
        "arn": "arn:aws:ivs:us-west-2:123456789:channel/fbc789c1-2c56-4ce6-a30a-d99275dc4481"
    }
}
```

要通过更新现有通道启用授权，请执行以下操作：

```
aws ivs update-channel --arn
arn:aws:ivs:us-west-2:693991300569:channel/742da049-fe9f-4f23-928e-c6753760a189 
--authorized
```

这只是一个示例；您必须在 `--arn` 之后指定自己的通道 ARN。与创建通道时一样，在更新响应中，`authorized` 为 `true`。

## API 请求（创建与更新）
<a name="private-channels-auth-api"></a>

有关使用情况信息，请参阅《IVS 低延迟直播功能 API 参考》中的 [CreateChannel](https://docs.aws.amazon.com//ivs/latest/LowLatencyAPIReference/API_CreateChannel.html) 和 [UpdateChannel](https://docs.aws.amazon.com//ivs/latest/LowLatencyAPIReference/API_UpdateChannel.html)。**

```
POST /CreateChannel HTTP/1.1
{
  "name": "<your channel name>",
  "authorized": true
}
```

```
POST /UpdateChannel HTTP/1.1
{
  "arn": "<channel arn>",
  "authorized": true
}
```