各製品の資料を入手。
詳細はこちら →MySQL のFederated Table としてPingOne のデータを連携利用する
SQL Gateway とODBC Driver を使ってPingOne のMySQL Federated Table を構築する。
最終更新日:2022-07-18
この記事で実現できるPingOne 連携のシナリオ
こんにちは!ドライバー周りのヘルプドキュメントを担当している古川です。
SQL Gateway を使って、MySQL リモーティングサービスを作成し、PingOne のMySQL Federated Table を構築できます。CData ODBC Driver for PingOne のMySQL インターフェースのdeamon になります。サービス起動後、MySQL のFEDERATED ストレージエンジンを使ってサーバーおよびテーブルを作成します。PingOne のデータ をMySQL テーブルのように使いましょう。
PingOne のデータへの接続
If you have not already done so, provide values for the required connection properties in the data source name (DSN). You can use the built-in Microsoft ODBC Data Source Administrator to configure the DSN. This is also the last step of the driver installation. See the "Getting Started" chapter in the help documentation for a guide to using the Microsoft ODBC Data Source Administrator to create and configure a DSN.
PingOne に接続するには以下のプロパティを設定します。
- Region:自身のPingOne 組織のデータがホスティングされている地域。
- AuthScheme:PingOne に接続する際に使用する認証の種類。
- WorkerAppEnvironmentId (デフォルトのPingOne ドメインを使用する場合に必要)、またはAuthorizationServerURL のいずれかで、下で説明するように設定します。
WorkerAppEnvironmentId の設定
WorkerAppEnvironmentId は、Worker アプリケーションが存在するPingOne 環境のID です。 このパラメータは、環境がデフォルトのPingOne ドメイン(auth.pingone)を利用している場合のみ使用されます。 これは、ヘルプドキュメントのカスタムOAuth アプリケーションの作成で説明するように、PingOne への認証に使用するカスタムOAuth アプリケーションを作成した後に設定します。
はじめに、このプロパティの値を見つけます。
- 自身のPingOne 組織のホームページからナビゲーションサイドバーに移動し、Environments をクリックします。
- OAuth / Worker のカスタムアプリケーションを作成した環境(通常はAdministrators)を見つけ、Manage Environment をクリックします。 環境のホームページが表示されます。
- 環境のホームページのナビゲーションサイドバーで、Applications をクリックします。
- リストから、OAuth またはWorker アプリケーションの詳細を見つけます。
-
Environment ID フィールドの値をコピーします。
以下の例に似たものになるはずです:
WorkerAppEnvironmentId='11e96fc7-aa4d-4a60-8196-9acf91424eca'
次に、WorkerAppEnvironmentId をEnvironment ID フィールドの値に設定します。
AuthorizationServerURL の設定
AuthorizationServerURL は、お使いのアプリケーションが配置されている環境のPingOne 認可サーバーのベースURL です。 このプロパティは、PingOne プラットフォームAPI ドキュメントで説明されているように、環境にカスタムドメインを設定した場合にのみ使用されます。 Custom Domains を参照してください。
OAuth でのPingOne への認証
PingOne はOAuth とOAuthClient 認証の両方をサポートしています。 上述の設定手順に加え、OAuth またはOAuthCliet 認証をサポートするために、さらに2つの手順を完了する必要があります。
- ヘルプドキュメントのカスタムOAuth アプリケーションの作成で説明するように、カスタムOAuth アプリケーションを作成して設定します。
- ドライバーがデータモデル内のエンティティにアクセスできるようにするには、ヘルプドキュメントのAdministrator Roles での説明のとおり、使用するアドミンユーザー / ワーカーアプリケーションに対して正しいロールを設定していることを確認してください。
- 以下のサブセクションで説明されているように、選択した認証スキームと認証フローに適切なプロパティを設定します。
OAuth(認可コードグラント)
AuthScheme をOAuth に設定します。
デスクトップアプリケーション
OAuth アクセストークンの取得およびリフレッシュ
以下を設定して、接続してください。
- InitiateOAuth:GETANDREFRESH。繰り返しOAuth の交換を行ったり、手動でOAuthAccessToken を設定する必要をなくすには、InitiateOAuth を使用します。
- OAuthClientId:カスタムOAuth アプリケーションを作成した際に取得したClient ID。
- OAuthClientSecret:カスタムOAuth アプリケーションを作成した際に取得したClient Secret。
- CallbackURL:カスタムOAuth アプリケーションの登録時に定義したリダイレクトURI。例:https://localhost:3333
接続すると、本製品 はデフォルトブラウザでPingOne のOAuth エンドポイントを開きます。ログインして、アプリケーションにアクセス許可を与えます。 ドライバーはこれでOAuth プロセスを完了します。
- ドライバーはPingOne からアクセストークンを取得し、それを使ってデータをリクエストします。
- OAuth 値はOAuthSettingsLocation で指定された場所に保存され、接続間で永続化されるようにします。
ドライバーはアクセストークンの期限が切れると自動的にリフレッシュします。
Web アプリケーションやヘッドレスマシン、クライアントクレデンシャルグラントを含むその他のOAuth メソッドについては、ヘルプドキュメントを参照してください。
SQL Gateway の設定
See the SQL Gateway Overview to set up connectivity to PingOne のデータ as a virtual MySQL database. You will configure a MySQL remoting service that listens for MySQL requests from clients. The service can be configured in the SQL Gateway UI.
PingOne データ のFEDERATED サーバーおよびテーブルを作成
After you have configured and started the service, create a FEDERATED server to simplify the process of creating FEDERATED tables:
FEDERATED サーバーの作成
The following statement will create a FEDERATED server based on the ODBC Driver for PingOne. Note that the username and password of the FEDERATED server must match a user account you defined on the Users tab of the SQL Gateway.
CREATE SERVER fedPingOne FOREIGN DATA WRAPPER mysql OPTIONS (USER 'sql_gateway_user', PASSWORD 'sql_gateway_passwd', HOST 'sql_gateway_host', PORT ####, DATABASE 'CData PingOne Sys');
FEDERATED テーブルの作成
To create a FEDERATED table using our newly created server, use the CONNECTION keyword and pass the name of the FEDERATED server and the remote table ([CData].[Administrators].Users). Refer to the following template for the statement to create a FEDERATED table:
CREATE TABLE fed_[cdata].[administrators].users ( ..., id TYPE(LEN), username TYPE(LEN), ..., ) ENGINE=FEDERATED DEFAULT CHARSET=latin1 CONNECTION='fedPingOne/[cdata].[administrators].users';
NOTE: The table schema for the FEDERATED table must match the remote table schema exactly. You can always connect directly to the MySQL remoting service using any MySQL client and run a SHOW CREATE TABLE query to get the table schema.
クエリの実行
You can now execute queries to the PingOne FEDERATED tables from any tool that can connect to MySQL, which is particularly useful if you need to JOIN data from a local table with data from PingOne. Refer to the following example:
SELECT fed_[cdata].[administrators].users.id, local_table.custom_field FROM local_table JOIN fed_[cdata].[administrators].users ON local_table.foreign_id = fed_[cdata].[administrators].users.id;