

# 在 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. 在 **Channel create** (頻道建立) 頁面，選擇 **Custom configuration** (自訂組態)。

1. 在**播放驗證**區段中，開啟**啟用影片播放的符記驗證要求**。

1. 依照其餘提示建立頻道。(請參閱 [開始使用 IVS 低延遲串流](getting-started.md))。

若要透過更新現有頻道來啟用授權：

1. 開啟 [Amazon IVS 主控台](https://console.aws.amazon.com/ivs)。如果您尚未使用頻道區域，請選擇頻道區域。

1. 在左側導覽功能表中，選擇 **Channels** (頻道)。

1. 選擇您要更新的頻道的核取方塊，然後選擇 **Edit** (編輯)。

1. 在**播放驗證**區段中，開啟**啟用影片播放的符記驗證要求**。

1. 按一下 **Save changes** (儲存變更)。

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

要在建立頻道時啟用授權：

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

如果區域位於本機 AWS 組態檔案中，您可以省略 `--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
}
```