---
sourceDocument: Xanadu API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - ja-JP

ft:publication_title :

    - Xanadu API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# AuthCredential - スコープ付き

# AuthCredential - スコープ付き {#ariaid-title1}

* リリースバージョン: Xanadu
* 
* 更新日 2024年08月01日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：6分

AuthCredential() API は、REST 要求の資格情報を構築できるようにするメソッドを提供します。  
次の順序でこれらの API を使用して、送信署名要求を生成します。

1. HttpRequestData：API 要求を構築します。
2. AuthCredential：資格情報オブジェクトを作成するか、既存のオブジェクトを更新します。資格情報を使用して、RequestAuthAPI クラスで要求に署名します。
3. RequestAuthAPI：要求に署名し、HttpRequestAuthedData オブジェクトを返します。
4. HttpRequestAuthedData：署名された要求に関する情報を取得します。
5. GlideHTTPRequest：署名された要求を送信します。
{#AuthCredentialAPI__ol_gvv_22t_tjb}

これらの API を使用する前に、認証 [アルゴリズムを構成し](https://www.servicenow.com/docs/access?context=configure-authentication-algorithm&version=xanadu&pubname=xanadu-platform-security&ft:locale=en-US) て要求に署名し、要求の認証に使用する認証情報に関連付ける必要があります。

空の AuthCredential オブジェクトを作成するか、既存の AuthCredential オブジェクトをインスタンス化するか、または StandardCredentialsProvider クラスを使用し、資格情報 \[discovery_credentials\] テーブルの資格情報レコードを使用して AuthCredential オブジェクトをインスタンス化することができます。空の AuthCredential オブジェクトを作成した場合は、setAttribute() メソッドを使用してオブジェクトにプロパティを追加します。{#AuthCredentialAPI__p_mpf_pjx_zjb}  
次の例は、 StandardCredentialsProvider を使用して AuthCredential をインスタンス化する方法を示しています。

    // Return an AuthCredential object using a Credential sys_id
    var credential = new sn_cc.StandardCredentialsProvider().getAuthCredentialByID("5b61c16f73533300f662cff8faf6a74b");

`sn_auth` 名前空間識別子を持つスコープ対象スクリプトで AuthCredential API を使用します。

## AuthCredential - AuthCredential(オブジェクト authCredential) {#ariaid-title2}

新しい AuthCredential オブジェクトをインスタンス化するか、既存のものを変更します。
空の AuthCredential オブジェクトを作成するか、既存の AuthCredential オブジェクトをインスタンス化するか、または StandardCredentialsProvider クラスを使用し、資格情報 \[discovery_credentials\] テーブルの資格情報レコードを使用して AuthCredential オブジェクトをインスタンス化することができます。空の AuthCredential オブジェクトを作成した場合は、setAttribute() メソッドを使用してオブジェクトにプロパティを追加します。
{#AuthCredential-AuthCredential_O__table_sjv_2sx_5jb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| authCredential | オブジェクト | オプション。既存の AuthCredential オブジェクトを更新するには、このパラメーターを含めます。 |
[表 : 1. パラメーター]

{#AuthCredential-AuthCredential_O__table_sjv_2sx_5jb}

## AuthCredential - getAttribute(文字列 key) {#ariaid-title3}

AuthCredential 属性の値を返します。
{#AuthCredential-getAttribute_S__table_ss5_hsx_5jb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| key | 文字列 | 値を返す属性のキーです。 空の AuthCredential オブジェクトを作成した場合は、 setAttribute() メソッドを使用してオブジェクトにプロパティを追加する必要があります。 資格情報レコードを使用して AuthCredential オブジェクトをインスタンス化した場合は、資格情報 \[discovery_credentials\] テーブルからフィールド名を渡して値にアクセスします。 |
[表 : 2. パラメーター]

{#AuthCredential-getAttribute_S__table_ss5_hsx_5jb} {#AuthCredential-getAttribute_S__table_ts5_hsx_5jb__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 3. 返される内容]

{#AuthCredential-getAttribute_S__table_ts5_hsx_5jb}  

    // 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) {#ariaid-title4}

AuthCredential オブジェクトの属性を設定します。
{#AuthCredential-setAttribute_S_S__table_off_jsx_5jb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| key | 文字列 | 設定する属性の名前です。空の AuthCredential オブジェクトを作成した場合、このメソッドを使用してオブジェクトにプロパティを追加する必要があります。資格情報レコードを使用して AuthCredential オブジェクトをインスタンス化した場合は、資格情報 \[discovery_credentials\] テーブルからフィールド資格名を渡して値を設定します。 |
| value | 文字列 | 属性の値です。 |
[表 : 4. パラメーター]

{#AuthCredential-setAttribute_S_S__table_off_jsx_5jb} {#AuthCredential-setAttribute_S_S__table_pff_jsx_5jb__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 5. 返される内容]

{#AuthCredential-setAttribute_S_S__table_pff_jsx_5jb}  

    // 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");


