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 개체를 만들거나, 기존 AuthCredential 개체를 인스턴스화하거나, StandardCredentialsProvider 클래스를 사용하여 자격 증명 [discovery_credentials] 테이블의 자격 증명 레코드를 사용하여 AuthCredential 개체를 인스턴스화할 수 있습니다. 빈 AuthCredential 객체를 만드는 경우 setAttribute() 메서드를 사용하여 객체에 속성을 추가합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| authCredential | 객체 | 옵션입니다. 이 매개변수를 포함하여 기존 AuthCredential 객체를 업데이트합니다. |
AuthCredential - getAttribute(String 키)
AuthCredential 특성의 값을 반환합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 키 | 문자열 | 값을 반환할 속성의 키입니다. 빈 AuthCredential 객체를 만든 경우 setAttribute() 메서드를 사용하여 객체에 속성을 추가해야 합니다. 자격 증명 기록을 사용하여 AuthCredential 객체를 인스턴스화한 경우 자격 증명 [discovery_credentials] 테이블에서 필드 이름을 전달하여 값에 액세스합니다. |
| 유형 | 설명 |
|---|---|
| void |
// 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(String 키, 문자열 값)
AuthCredential 개체의 속성을 설정합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 키 | 문자열 | 설정할 속성의 이름입니다. 빈 AuthCredential 개체를 만든 경우 이 메서드를 사용하여 개체에 속성을 추가해야 합니다. 자격 증명 기록을 사용하여 AuthCredential 객체를 인스턴스화한 경우 자격 증명 [discovery_credentials] 테이블에서 필드 이름을 전달하여 값을 설정합니다. |
| 값 | 문자열 | 속성의 값입니다. |
| 유형 | 설명 |
|---|---|
| void |
// 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");