AuthCredential - スコープ付き
AuthCredential() API は、REST 要求の資格情報を構築できるようにするメソッドを提供します。
- HttpRequestData:API 要求を構築します。
- AuthCredential:資格情報オブジェクトを作成するか、既存のオブジェクトを更新します。資格情報を使用して、RequestAuthAPI クラスで要求に署名します。
- RequestAuthAPI:要求に署名し、HttpRequestAuthedData オブジェクトを返します。
- HttpRequestAuthedData:署名された要求に関する情報を取得します。
- GlideHTTPRequest:署名された要求を送信します。
これらの API を使用する前に、認証 アルゴリズムを構成し て要求に署名し、要求の認証に使用する認証情報に関連付ける必要があります。
空の AuthCredential オブジェクトを作成するか、既存の AuthCredential オブジェクトをインスタンス化するか、または StandardCredentialsProvider クラスを使用し、資格情報 [discovery_credentials] テーブルの資格情報レコードを使用して AuthCredential オブジェクトをインスタンス化することができます。空の AuthCredential オブジェクトを作成した場合は、setAttribute() メソッドを使用してオブジェクトにプロパティを追加します。
// Return an AuthCredential object using a Credential sys_id
var credential = new sn_cc.StandardCredentialsProvider().getAuthCredentialByID("5b61c16f73533300f662cff8faf6a74b");sn_auth 名前空間識別子を持つスコープ対象スクリプトで AuthCredential API を使用します。
AuthCredential - AuthCredential(オブジェクト authCredential)
新しい AuthCredential オブジェクトをインスタンス化するか、既存のものを変更します。
空の AuthCredential オブジェクトを作成するか、既存の AuthCredential オブジェクトをインスタンス化するか、または StandardCredentialsProvider クラスを使用し、資格情報 [discovery_credentials] テーブルの資格情報レコードを使用して AuthCredential オブジェクトをインスタンス化することができます。空の AuthCredential オブジェクトを作成した場合は、setAttribute() メソッドを使用してオブジェクトにプロパティを追加します。
| 名前 | タイプ | 説明 |
|---|---|---|
| authCredential | オブジェクト | オプション。既存の AuthCredential オブジェクトを更新するには、このパラメーターを含めます。 |
AuthCredential - getAttribute(文字列 key)
AuthCredential 属性の値を返します。
| 名前 | タイプ | 説明 |
|---|---|---|
| key | 文字列 | 値を返す属性のキーです。 空の AuthCredential オブジェクトを作成した場合は、 setAttribute() メソッドを使用してオブジェクトにプロパティを追加する必要があります。 資格情報レコードを使用して AuthCredential オブジェクトをインスタンス化した場合は、資格情報 [discovery_credentials] テーブルからフィールド名を渡して値にアクセスします。 |
| タイプ | 説明 |
|---|---|
| なし |
// Define the HttpRequestData object
var endpoint= "https://third-party-endpoint";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod("PUT");
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);
httpRequestData.addHeader('x-amz-acl', 'public-read' );
// Get AuthCredential object and set an attribute
var credential = new sn_auth.AuthCredential();
credential.setAttribute("user_name", "admin");
// Sign the request and return an AuthCredential attribute value
var signingAPI = new sn_auth.RequestAuthAPI(httpRequestData, credential);
var signingCredential = signingAPI.getAuthCredential();
name = signingCredential.getAttribute("name");
AuthCredential - setAttribute(文字列 key, 文字列 value)
AuthCredential オブジェクトの属性を設定します。
| 名前 | タイプ | 説明 |
|---|---|---|
| key | 文字列 | 設定する属性の名前です。空の AuthCredential オブジェクトを作成した場合、このメソッドを使用してオブジェクトにプロパティを追加する必要があります。資格情報レコードを使用して AuthCredential オブジェクトをインスタンス化した場合は、資格情報 [discovery_credentials] テーブルからフィールド資格名を渡して値を設定します。 |
| value | 文字列 | 属性の値です。 |
| タイプ | 説明 |
|---|---|
| なし |
// Define the HttpRequestData object
var endpoint= "https://third-party-endpoint";
var httpRequestData = new sn_auth.HttpRequestData();
httpRequestData.setEndpoint(endpoint);
httpRequestData.setService('s3');
httpRequestData.setRegion('us-east-1');
httpRequestData.setHttpMethod("PUT");
var content = "Action=SendMessage&MessageBody=This is a test message";
httpRequestData.setContent(content);
httpRequestData.addHeader('x-amz-acl' , 'public-read' );
// Get AuthCredential object and set an attribute
var credential = new sn_auth.AuthCredential();
credential.setAttribute("user_name", "admin");