OAuth の使用
このセクションでは、connector を使って、OAuth をサポートする任意のデータソースを認証する方法を説明します。
OAuth では認証するユーザーにブラウザでJSON との通信を要求します。次のセクションで説明するとおり、connector はさまざまな方法でこれをサポートします。
次の手順に従う前に、サービスにOAuth アプリを登録してOAuthClientId およびOAuthClientSecret を取得する必要があります。
デスクトップアプリケーション
次の接続プロパティを設定して、接続してください。
- OAuthVersion:OAuth バージョン1.0 か2.0 のいずれかに設定します。
- OAuthRequestTokenURL:OAuth 1.0 に必要です。OAuth 1.0 では、これがアプリケーションがリクエストトークンをリクエストするURL です。
- OAuthAuthorizationURL:OAuth 1.0 および2.0 に必要です。これは、ユーザーがサービスにログインして、アプリケーションにアクセス許可を与えるURLです。OAuth 1.0 では、権限が与えられるとリクエストトークンが認可されます。
- OAuthAccessTokenURL:OAuth 1.0 および2.0 に必要です。これは、アクセストークンがリクエストされるURLです。OAuth 1.0 では、認可されたリクエストトークンはアクセストークンと交換されます。
- OAuthRefreshTokenURL:OAuth 2.0 に必要です。OAuth 2.0 では、古いトークンの期限が切れたときは、このURL でリフレッシュトークンと新しいアクセストークンと交換します。データソースによっては、アクセストークンと同じURL である場合がありますので、注意してください。
- OAuthClientId:アプリケーション設定のクライアントID に設定。これはコンシューマーキーとも呼ばれます。
- OAuthClientSecret:アプリケーション設定のクライアントシークレットに設定。これはコンシューマーシークレットとも呼ばれます。
- CallbackURL:http://localhost:33333 に設定。アプリケーション設定でリダイレクトURL を指定した場合には、一致している必要があります。
- InitiateOAuth:GETANDREFRESH に設定。InitiateOAuth を使って、OAuth 交換や、手動での接続文字列のアクセストークン設定の繰り返しを避けられます。
- コールバックURL からアクセストークンを取得し、リクエストを認証します。
- アクセストークンの期限が切れたときにはリフレッシュしてください。
- OAuth 値 in OAuthSettingsLocation を保存し、接続の間に維持されるようにします。
JWT
The connector supports using JWT as an authorization grant in situations where a user cannot perform an interactive sign-on. After setting the following connection properties, you are ready to connect:
- OAuthVersion: Set this to 2.0
- OAuthAccessTokenURL: Set this to the URL where the JWT is exchanged for an access token.
- OAuthJWTCert: Set this to the certificate you want to use. In most cases this will be a path to a PEM or PFX file.
- OAuthJWTCertType: Set this to the correct certificate type. In most cases this will either PEMKEY_FILE or PFXFILE.
- OAuthJWTCertPassword: If the certificate is encrypted, set this to the encryption password.
- OAuthJWTIssuer: Set this to the issuer. This corresponds to the iss field in the JWT.
- InitiateOAuth: Set this to GETANDREFRESH.
Note that the JWT signature algorithm cannot be set directly. Only the RS256 algorithm is supported.
The connector will then construct a JWT including following fields, and submit it to OAuthAccessTokenURL for an access token.
- scope This will come from Scope if it is provided.
- aud This will come from OAuthJWTAudience if it is provided.
- iss This will come from OAuthJWTIssuer.
- iat This is the time when the JWT is generated.
- exp This is the value of iat plus the value of OAuthJWTValidityTime.
- sub This will come from OAuthJWTSubject if it is provided.