---
schema_version: "1"
id: 741d4e3ed5724c8e6e37bbb1039e6958ad275885e209820b64a32963c4cb759f
title: 设置 Amazon Redshift IAM Identity Center OAuth
collection: tableau
version: current
locale: zh-cn
portal_url: https://docs.salesforce.com/tableau/current/zh-cn/server/config_oauth_redshift_iam_idc.md
canonical_url: https://help.tableau.com/current/server/zh-cn/config_oauth_redshift_iam_idc.htm
source_site: help.tableau.com
content_type: documentation
content_hash: 6eb968d604007498022f51278e712be08396a78ee498f5bdeda8eabcf4f90536
description: Set up Amazon Redshift IAM Identity Center OAuth federation, with driver setup and troubleshooting.
---
[跳转到主要内容](#main-content)

# 设置 Amazon Redshift IAM Identity Center OAuth

从 Tableau 2023.3.2 开始，您可以使用 OAuth 2.0/OIDC 将外部身份提供程序的身份联合到 Amazon Redshift。

这些说明适用于较新的 AWS IAM IDC 服务。有关原始 IAM 集成，请参见[设置 Amazon Redshift IAM OAuth](https://help.tableau.com/current/server/zh-cn/config_oauth_redshift_iam.htm)。

根据身份提供程序的不同，配置集成需要执行不同的步骤。这是一个简略概述。Tableau 无法提供有关如何配置 AWS 或 IDP 的详细说明，但这是一般方法。

有关使用 Redshift 实现身份验证的一些详细示例，请参见“[使用 AWS IAM Identity Center 将 Tableau 和 Okta 与 Amazon Redshift 集成](https://aws.amazon.com/blogs/big-data/integrate-tableau-and-okta-with-amazon-redshift-using-aws-iam-identity-center/)”和“[使用 AWS IAM Identity Center 将 Tableau 和 Microsoft Entra ID 与 Amazon Redshift 集成](https://aws.amazon.com/blogs/big-data/integrate-tableau-and-microsoft-entra-id-with-amazon-redshift-using-aws-iam-identity-center/)”。

## 步骤 1：配置 IDP

1. 在 IDP 上为 Tableau Desktop 和 Tableau Server 或 Tableau Cloud 创建 OAuth 客户端。Desktop 客户端应启用 `PKCE` 并使用 `http://localhost` 重定向。
2. 添加用于角色授权的任何必需的自定义声明。
3. 创建 Tableau OAuth 配置文件。请参见 [GitHub](https://tableau.github.io/connector-plugin-sdk/docs/oauth "GitHub 上用于创建 Tableau OAuth 配置文件的文档。") 上的文档和[示例](https://github.com/tableau/connector-plugin-sdk/tree/master/samples/components/oauth "GitHub 上用于创建 Tableau OAuth 配置文件的示例。")。我们欢迎提供其他 IDP 的示例。
    
    1. 请务必在 Tableau OAuth 配置 ID 前添加“`custom_`”前缀。
        
        **注意：**Oauth 配置 ID 的最大限制为 36 个字符。长于此长度的 ID 可能不会生成错误，但将不起作用。
    2. 如果您的 IDP 支持动态本地主机端口，则禁用 `OAUTH_CAP_FIXED_PORT_IN_CALLBACK_URL`。如果没有，请确保将多个本地主机回调 URL 添加到配置文件和 IDP 上的允许列表中。
4. 在与桌面主机（Tableau Desktop、Tableau Prep Builder、Tableau Bridge）上的每个应用程序以及将使用 OAuth 的每个 Tableau Server 和 Tableau Cloud 站点上每个应用程序关联的 `OAuthConfigs` 文件夹中，安装新的Tableau OAuth 配置文件。

## 步骤 2：配置 IDP 和 AWS 上的角色

有关执行此操作的信息，请参见 AWS 文档。

## 步骤 3：连接到 Redshift

1. 连接到 Redshift。
2. 为“身份验证”选择 OAuth。
3. 为“联合类型”选择 Identity Center。
4. （可选）如有必要，请指定“Identity Center 命名空间”。

![](/tableau/current/zh-cn/server/zh-cn/Img/redshift_oauth_idc_connect.png "“Redshift 连接”对话框")

正确配置后，您将被重定向到 IDP 以对 Tableau 的令牌进行身份验证和授权。Tableau 将收到访问令牌和刷新令牌。它将访问令牌发送给驱动程序进行身份验证。

## 令牌

默认情况下，edshift OAuth to IAM IDC 将访问令牌传递给驱动程序。对于本地客户（包括使用 Tableau Bridge 的客户），您可以改用 TDC 文件来传递 ID 令牌。

<connection-customization class='redshift' enabled='true' version='10.0'>
	<vendor name='redshift' />
	<driver name='redshift' />
	<customizations>
		<customization name='CAP\_OAUTH\_FEDERATE\_ID\_TOKEN' value='yes'/>
	</customizations>
</connection-customization>

有关配置和安装 .tdc 文件的详细信息，请参见[自定义和调整连接](https://help.tableau.com/current/pro/desktop/zh-cn/connect_customize.htm)和[将 .tdc 文件与 Tableau Server 配合使用](https://help.salesforce.com/s/articleView?id=001458291&type=1)。

## Okta

如果使用 Okta，最好使用“自定义授权服务器”而不是“组织授权服务器”。自定义授权服务器更加灵活。默认情况下会创建自定义授权服务器，称为“默认”。授权 URL 应如下所示：

https://${yourOktaDomain}/oauth2/{authServerName}/v1/authorize

![](/tableau/current/zh-cn/server/zh-cn/Img/redshift_oauth_idc_okta_800x332.png)

## 更新驱动程序

对于使用 IAM IDC 服务的 Redshift OAuth，您需要至少使用 2.x 版本的 ODBC 驱动程序。下载在 [https://github.com/aws/amazon-redshift-odbc-driver/tags](https://github.com/aws/amazon-redshift-odbc-driver/tags "适用于 Redshift ODBC 版本 2 的驱动程序下载") 上找到的最新版本的 Redshift ODBC 驱动程序。请注意，目前没有适用于 OSX 的 v2 驱动程序。

## Redshift IAM IDC OAuth 故障排除

诊断错误的最佳方法是从图片中移除 Tableau。您可以使用驱动程序管理器或类似的工具进行测试。这只是为了故障排除 - 您不应该使用 DSN 或“其他 ODBC”连接器来常规使用此功能。为了确保测试有效，除群集信息、数据库、令牌和命名空间外，参数应与下面所示相同。

如果您在第一次连接时看到来自驱动程序的无效/过期令牌的错误消息（错误消息中将包含类似 \[28000\] 或 \[08001\] 的 SQLState 错误代码），则 Tableau 已成功完成 OAuth 流程，并且驱动程序失败。这意味着 AWS 端或 IDP 端存在配置错误。驱动程序还可能返回权限或授权错误，这也不受 Tableau 的控制。

在开始测试之前，您首先需要获取访问令牌（IAM IDC 的默认设置）或刷新令牌（如果自定义）以发送给驱动程序。

这是 Okta 的示例。几乎所有 IDP 都有一种非常相似的方法来做到这一点。请注意，若要使用此流程，您需要启用资源所有者密码授予类型。替换 IDP URL、客户端密文、客户端 ID、用户名和密码。

curl -X POST "https://OKTA\_URL/v1/token" \\  
\-H 'accept: application/json' \\  
\-H "Authorization: Basic $(echo -n 'CLIENTID:CLIENTSECRET' | base64)" \\  
\-H "Content-Type: application/x-www-form-urlencoded" \\  
\-d "grant\_type=password&username=USER&password=PASSWORD&scope=openid"

获得令牌后，您可以使用 DSN 进行测试。对于 Windows，您可以使用 ODBC 驱动程序管理器。在 Linux 上，您可以使用 Tableau Server 附带的 customer-bin 文件夹中的 isql 命令行工具。

Tableau 建议您不要使用其他插件进行测试，因为它们可能无法在服务器环境中工作。他们要么使用固定的 AWS 配置文件，要么需要直接访问浏览器。

下面是在 Windows 上使用 ODBC 驱动程序管理器的示例。

![](/tableau/current/zh-cn/server/zh-cn/Img/redshift_oauth_idc_troubleshoot.png)