

 Amazon Redshift 將不再支援從修補程式 198 開始建立新的 Python UDFs。現有 Python UDF 將繼續正常運作至 2026 年 6 月 30 日。如需詳細資訊，請參閱[部落格文章](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用身分提供者外掛程式
<a name="python-connect-identity-provider-plugins"></a>

如需如何使用身分提供者外掛程式的一般資訊，請參閱[提供 IAM 登入資料的選項](options-for-providing-iam-credentials.md)。如需如何管理 IAM 身分的相關資訊 (包括 IAM 角色的最佳實務)，請參閱 [Amazon Redshift 中的身分和存取管理](redshift-iam-authentication-access-control.md)。

## 使用 ADFS 身分提供者外掛程式進行身分驗證
<a name="python-connect-identity-provider-active-dir"></a>

以下是使用 Active Directory Federation Service (ADFS) 身分提供者外掛程式來針對連線至 Amazon Redshift 資料庫的使用者進行驗證的範例。

```
>>> con = redshift_connector.connect(
    iam=True,
    database='dev',
    host='my-testing-cluster.abc.us-east-2.redshift.amazonaws.com',
    cluster_identifier='my-testing-cluster',
    credentials_provider='AdfsCredentialsProvider',
    user='brooke@myadfshostname.com',
    password='Hunter2',
    idp_host='myadfshostname.com'
)
```

## 使用 Azure 身分提供者外掛程式進行身分驗證
<a name="python-connect-identity-provider-azure"></a>

以下是使用 Azure 身分提供者外掛程式進行身分驗證的範例。您可以為 Azure 企業應用程式建立 `client_id` 和 `client_secret` 的值，如下所示。

```
>>>  con = redshift_connector.connect(
    iam=True,
    database='dev',
    host='my-testing-cluster.abc.us-east-2.redshift.amazonaws.com',
    cluster_identifier='my-testing-cluster',
    credentials_provider='AzureCredentialsProvider',
    user='brooke@myazure.org',
    password='Hunter2',
    idp_tenant='my_idp_tenant',
    client_id='my_client_id',
    client_secret='my_client_secret',
    preferred_role='arn:aws:iam:123:role/DataScientist'
)
```

## 使用 AWS IAM Identity Center 身分提供者外掛程式進行身分驗證
<a name="python-connect-identity-provider-aws-idc"></a>

 以下是使用 IAM Identity Center AWS 身分提供者外掛程式進行身分驗證的範例。

```
with redshift_connector.connect(
credentials_provider='BrowserIdcAuthPlugin',
host='my-testing-cluster.abc.us-east-2.redshift.amazonaws.com',
database='dev',
idc_region='us-east-1',
issuer_url='https://identitycenter.amazonaws.com/ssoins-790723ebe09c86f9',
idp_response_timeout=60,
listen_port=8100,
idc_client_display_name='Test Display Name',
# port value of 5439 is specified by default
)
```

## 使用 Azure Browser 身分提供者外掛程式進行身分驗證
<a name="python-connect-identity-provider-azure-browser"></a>

以下是使用 Azure Browser 身分提供者外掛程式來針對連線至 Amazon Redshift 資料庫的使用者進行驗證的範例。

由使用者提供登入憑據的瀏覽器會進行多重要素驗證。

```
>>>con = redshift_connector.connect(
    iam=True,
    database='dev',
    host='my-testing-cluster.abc.us-east-2.redshift.amazonaws.com',
    cluster_identifier='my-testing-cluster',
    credentials_provider='BrowserAzureCredentialsProvider',
    idp_tenant='my_idp_tenant',
    client_id='my_client_id',
)
```

## 使用 Okta 身分提供者外掛程式進行身分驗證
<a name="python-connect-identity-provider-okta"></a>

以下是使用 Okta 身分提供者外掛程式進行身分驗證的範例。您可以透過 Okta 應用程式取得 `idp_host`、`app_id` 和 `app_name` 的值。

```
>>> con = redshift_connector.connect(
    iam=True,
    database='dev',
    host='my-testing-cluster.abc.us-east-2.redshift.amazonaws.com',
    cluster_identifier='my-testing-cluster',
    credentials_provider='OktaCredentialsProvider',
    user='brooke@myazure.org',
    password='hunter2',
    idp_host='my_idp_host',
    app_id='my_first_appetizer',
    app_name='dinner_party'
)
```

## 搭配使用 JumpCloud 與一般 SAML 瀏覽器身分提供者外掛程式來進行身分驗證
<a name="python-connect-identity-provider-jumpcloud"></a>

以下是搭配使用 JumpCloud 與一般 SAML 瀏覽器身分提供者外掛程式來進行身分驗證的範例。

密碼是必要參數。但是，您不必輸入此參數，因為瀏覽器會進行多重要素驗證。

```
>>> con = redshift_connector.connect(
    iam=True,
    database='dev',
    host='my-testing-cluster.abc.us-east-2.redshift.amazonaws.com',
    cluster_identifier='my-testing-cluster',
    credentials_provider='BrowserSamlCredentialsProvider',
    user='brooke@myjumpcloud.org',
    password='',
    login_url='https://sso.jumpcloud.com/saml2/plustwo_melody'
)
```