이 페이지는 Apigee 및 Apigee Hybrid에 적용됩니다.
Apigee Edge 문서 보기
제목
이를 사용하면 액세스 토큰과 연결된 커스텀 속성을 추가하거나 업데이트할 수 있습니다. 커스텀 속성에는 부서 이름, 고객 ID, 세션 식별자 등이 포함될 수 있습니다. 토큰 및 승인 코드 맞춤설정도 참조하세요.
커스텀 속성만 추가하거나 수정할 수 있습니다. 이 정책을 사용하여 scope, status, expires_in, developer_email, client_id, org_name, refresh_count 등의 필드를 변경할 수 없습니다. 속성이 이미 존재하는 경우 이 정책이 속성을 업데이트합니다. 속성이 존재하지 않는 경우 정책이 속성을 추가합니다. 참조된 액세스 토큰은 유효하고 승인된 상태여야 합니다.
이 정책은 확장 가능한 정책이며, 이 정책을 사용하면 Apigee 라이선스에 따라 비용 또는 사용률이 영향을 받을 수 있습니다. 정책 유형 및 사용 영향에 대한 자세한 내용은 정책 유형을 참조하세요.
샘플
기본 예시
다음은 OAuth 2.0 액세스 토큰을 업데이트하는 데 사용되는 정책 예시입니다. 아래 예시에서는 access_token
이라는 쿼리 매개변수를 찾아 요청 메시지에서 액세스 토큰을 찾습니다. 클라이언트 앱에서 액세스 토큰이 제공되면 아래 정책은 쿼리 매개변수의 액세스 토큰을 찾습니다. 그런 다음 액세스 토큰의 프로필이 업데이트됩니다. 정책은 department.id
라는 커스텀 속성을 프로필에 추가합니다.
<SetOAuthV2Info name="SetOAuthV2Info"> <AccessToken ref="request.queryparam.access_token"></AccessToken> <Attributes> <Attribute name="department.id" ref="request.queryparam.department_id"></Attribute> </Attributes> </SetOAuthV2Info>
요소 참조
요소 참조는 SetOAuthV2 정책의 요소 및 속성을 설명합니다.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <SetOAuthV2Info async="false" continueOnError="false" enabled="true" name="SetOAuthV2Info-1"> <DisplayName>Set OAuth v2.0 Info 1</DisplayName> <AccessToken ref={some-variable}></AccessToken> <Attributes/> </SetOAuthV2Info> </xml>
<SetOAuthV2Info> 속성
<SetOAuthV2Info async="false" continueOnError="false" enabled="true" name="Set-OAuth-v20-Info-1">
다음 표는 모든 정책 상위 요소의 공통 속성에 대해 설명합니다.
속성 | 설명 | 기본값 | 현재 상태 |
---|---|---|---|
name |
정책의 내부 이름입니다. 원하는 경우 |
해당 없음 | 필수 |
continueOnError |
정책이 실패할 경우 오류가 반환되도록 하려면 정책이 실패해도 흐름 실행이 계속되도록 하려면 |
false | 선택사항 |
enabled |
정책을 시행하려면 정책을 중지하려면 |
참 | 선택사항 |
async |
이 속성은 지원이 중단되었습니다. |
false | 지원 중단됨 |
<DisplayName> 요소
name
속성 외에도 이 요소를 사용하여 관리 UI 프록시 편집기의 정책에 다른 자연어 이름으로 라벨을 지정합니다.
<DisplayName>Policy Display Name</DisplayName>
기본값 |
해당 없음 이 요소를 생략하면 정책 |
---|---|
현재 상태 | 선택사항 |
유형 | 문자열 |
<AccessToken> 요소
액세스 토큰이 위치한 변수를 식별합니다. 예를 들어 액세스 토큰이 요청 메시지에 쿼리 매개변수로 연결되면 request.queryparam.access_token
을 지정합니다. 토큰을 참조하는 모든 유효한 변수를 사용할 수 있습니다. 또는 리터럴 토큰 문자열(드문 사례)을 전달할 수도 있습니다.
<AccessToken ref="request.queryparam.access_token"></AccessToken>
기본값: | 해당 사항 없음 |
Presence: | 필수 |
유형: | 문자열 |
속성
속성 | 설명 | 기본값 | Presence |
---|---|---|---|
ref |
액세스 토큰 변수입니다. 일반적으로 흐름 변수에서 가져옵니다. |
해당 사항 없음 | 선택사항 |
<Attributes> 요소
수정 또는 보강될 액세스 토큰 프로필의 속성 집합입니다.
기본값: | 해당 사항 없음 |
Presence: | 필수 |
유형: | 해당 사항 없음 |
<Attributes>/<Attribute> 요소
업데이트할 개별 속성입니다.
name 속성은 업데이트될 액세스 토큰 프로필의 커스텀 속성을 식별합니다. 이 예시에서는 참조된 변수 값과 정적 값을 사용하는 방법을 보여줍니다.
<Attributes> <Attribute name="department.id" ref="request.queryparam.department_id"></Attribute> <Attribute name="foo">bar</Attribute> </Attributes>
기본값: | 해당 사항 없음 |
Presence: | 선택사항 |
유형: | 해당 사항 없음 |
속성
속성 | 설명 | 기본값 | 현재 상태 |
---|---|---|---|
이름 | 추가하거나 변경할 프로필 속성의 이름입니다. | 해당 사항 없음 | |
ref |
프로필 속성에 할당할 값입니다. |
해당 사항 없음 | 선택사항 |
흐름 변수
성공하면 다음 흐름 변수가 설정됩니다.
oauthv2accesstoken.{policyName}.access_token
oauthv2accesstoken.{policyName}.client_id
oauthv2accesstoken.{policyName}.refresh_count
oauthv2accesstoken.{policyName}.organization_name
oauthv2accesstoken.{policyName}.expires_in //--in seconds
oauthv2accesstoken.{policyName}.refresh_token_expires_in //--in seconds
oauthv2accesstoken.{policyName}.issued_at
oauthv2accesstoken.{policyName}.status
oauthv2accesstoken.{policyName}.api_product_list
oauthv2accesstoken.{policyName}.token_type
oauthv2accesstoken.{policyName}.{custom_attribute_name}
스키마
각 정책 유형은 XML 스키마(.xsd
)로 정의됩니다. 참고로 GitHub에서 정책 스키마를 사용할 수 있습니다.
오류 참조
This section describes the fault codes and error messages that are returned and fault variables that are set by Apigee when this policy triggers an error. This information is important to know if you are developing fault rules to handle faults. To learn more, see What you need to know about policy errors and Handling faults.
Runtime errors
These errors can occur when the policy executes.
Fault code | HTTP status | Cause |
---|---|---|
steps.oauth.v2.access_token_expired |
500 |
The access token sent to the policy is expired. |
steps.oauth.v2.invalid_access_token |
500 |
The access token sent to the policy is invalid. |
steps.oauth.v2.InvalidAPICallAsNoApiProductMatchFound |
401 |
Please see Oauth2.0 Access Token Verification throws "Invalid API call as no apiproduct match found" error for information about troubleshooting this error. |
Deployment errors
Refer to the message reported in the UI for information about deployment errors.
Fault variables
These variables are set when this policy triggers an error at runtime.
Variables | Where | Example |
---|---|---|
fault.name="fault_name" |
fault_name is the name of the fault, as listed in the Runtime errors table above. The fault name is the last part of the fault code. | fault.name = "invalid_access_token" |
oauthV2.policy_name.failed |
policy_name is the user-specified name of the policy that threw the fault. | oauthV2.SetTokenInfo.failed = true |
oauthV2.policy_name.fault.name |
policy_name is the user-specified name of the policy that threw the fault. | oauthV2.SetTokenInfo.fault.name = invalid_access_token |
oauthv2.policy_name.fault.cause |
policy_name is the user-specified name of the policy that threw the fault. | oauthV2.SetTokenInfo.cause = Invalid Access Token |
Example error response
{ "fault": { "faultstring": "Invalid Access Token", "detail": { "errorcode": "keymanagement.service.invalid_access_token" } } }
Example fault rule
<FaultRule name=SetOAuthV2Info Faults"> <Step> <Name>AM-InvalidTokenResponse</Name> <Condition>(fault.name = "invalid_access_token")</Condition> </Step> <Condition>(oauthV2.failed = true) </Condition> </FaultRule>