在此頁面上:瞭解如何在Adobe Journey Optimizer中設定自訂管道的OAuth 2.0驗證,包括權杖要求承載、認證路徑、權杖擷取和傳遞要求中的權杖位置。
當您在建立自訂通道時選取 OAuth 2.0 作為驗證型別時,請設定Adobe Journey Optimizer用來從您的授權伺服器擷取存取權杖的權杖要求。
Journey Optimizer使用endpoint、method、request和policy設定來傳送Token要求。 然後它使用tokenPath從回應中擷取存取權杖,並使用locationConfig將其新增至傳遞要求。
OAuth 2.0驗證裝載會設定對 權杖端點 的要求。 它與傳送至您自訂通道傳遞端點的訊息裝載不同。
設定權杖請求 token-request
使用以下範例來設定您的Token要求。 將範例端點和認證值取代為您的授權伺服器所需的值。 範例中的headers和queryParams專案是選用專案:如果您的權杖端點不需要它們,請移除它們,並從credentialPaths移除相符的專案。
表單本文範例 form-body-example
當權杖端點預期表單欄位(例如grant_type、client_id或client_secret)時,請使用form裝載。
{
"type": "oauth2",
"endpoint": {
"uri": "https://auth.example.com/oauth/token"
},
"method": "post",
"request": {
"headers": [
{
"key": "sampleHeaderKey",
"value": "sampleHeaderValue"
}
],
"queryParams": [
{
"key": "sampleQueryParamKey",
"value": "sampleQueryParamValue"
}
],
"payload": {
"type": "form",
"content": [
{
"key": "grant_type",
"value": "client_credentials"
},
{
"key": "client_id",
"value": "your-client-id"
},
{
"key": "client_secret",
"value": "your-client-secret"
}
],
"includeNullValues": false
}
},
"response": {
"type": "json"
},
"policy": {
"timeoutInMilliseconds": 30000,
"cache": {
"enabled": true,
"ttlInSeconds": 300
},
"retry": {
"enabled": false,
"maxRetryCount": 3
}
},
"credentialPaths": [
"header.sampleHeaderKey",
"queryParam.sampleQueryParamKey",
"payload.client_id",
"payload.client_secret"
],
"tokenPath": "access_token",
"locationConfig": {
"key": "Authorization",
"location": "header"
}
}
對於form裝載,每個認證路徑都使用表單欄位金鑰,例如payload.client_secret。 認證路徑中不包含content或陣列索引。
JSON內文範例 json-body-example
當權杖端點需要JSON要求內文時,請使用json裝載。
{
"type": "oauth2",
"endpoint": {
"uri": "https://auth.example.com/oauth/token"
},
"method": "post",
"request": {
"headers": [
{
"key": "sampleHeaderKey",
"value": "sampleHeaderValue"
}
],
"queryParams": [
{
"key": "sampleQueryParamKey",
"value": "sampleQueryParamValue"
}
],
"payload": {
"type": "json",
"content": {
"grant_type": "client_credentials",
"client_id": "your-client-id",
"client_secret": "your-client-secret"
},
"includeNullValues": false
}
},
"response": {
"type": "json"
},
"policy": {
"timeoutInMilliseconds": 30000,
"cache": {
"enabled": true,
"ttlInSeconds": 300
},
"retry": {
"enabled": false,
"maxRetryCount": 3
}
},
"credentialPaths": [
"header.sampleHeaderKey",
"queryParam.sampleQueryParamKey",
"payload.client_id",
"payload.client_secret"
],
"tokenPath": "access_token",
"locationConfig": {
"key": "Authorization",
"location": "header"
}
}
Oauth 2.0欄位 oauth2-fields
typeoauth2。endpoint.urimethodpost進行Token要求。request.headersrequest.queryParamsrequest.payloadform和json裝載。request.payload.includeNullValuesresponse.typejson。policy.timeoutInMillisecondspolicy.cachepolicy.retrycredentialPathstokenPathaccess_token或data.access_token。locationConfiglocationConfig.keyAuthorization。locationConfig.locationheader或queryParam。當權杖快取啟用時,Journey Optimizer會在設定的快取期間內重複使用OAuth權杖,而不是針對每個傳送請求呼叫權杖端點。
識別認證欄位 credential-paths
使用credentialPaths識別哪些要求欄位包含認證。 如果標頭或查詢引數包含認證,請將其路徑以及任何認證路徑納入請求內文中。 上述範例將範例標題和查詢引數值識別為認證;調整此清單以符合您的請求。
header.header.sampleHeaderKeyqueryParam.queryParam.sampleQueryParamKeypayload.payload.client_secret套用下列規則:
- 路徑必須以
header、queryParam或payload開頭,並使用點做為分隔符號。 - 對於
form承載,請使用payload.<formFieldKey>。 - 對於
json負載,請使用JSON物件路徑,例如payload.client_id或payload.credentials.client_secret。 不要在路徑中包含content。 - 不支援空白路徑區段。 例如,
payload..client_id無效。
對於巢狀JSON內文,請使用此設定摘要中所示的點標籤法:
{
"request": {
"payload": {
"type": "json",
"content": {
"credentials": {
"client_id": "your-client-id",
"client_secret": "your-client-secret"
}
},
"includeNullValues": false
}
},
"credentialPaths": [
"payload.credentials.client_id",
"payload.credentials.client_secret"
]
}
擷取存取權杖 token-path
tokenPath定義存取權杖在OAuth 2.0權杖回應中的位置。
針對下列回應,將tokenPath設為access_token:
{
"access_token": "example-access-token",
"token_type": "Bearer",
"expires_in": 3600
}
針對巢狀回應,將tokenPath設為data.access_token:
{
"data": {
"access_token": "example-access-token"
}
}
將權杖新增至傳遞請求 token-location
locationConfig會定義Journey Optimizer在呼叫自訂通道傳遞端點時新增擷取的Token的位置。
若要在Authorization標頭中傳送Token,請使用:
{
"locationConfig": {
"key": "Authorization",
"location": "header"
}
}
headerqueryParam限制和驗證規則 limits
endpoint.uripolicy.timeoutInMillisecondspolicy.cache.ttlInSecondsrequest.headersrequest.queryParamsrequest.payload.type=formtokenPathcredentialPathsheader、queryParam或payload開頭,並使用點做為分隔符號。後續步驟 next-steps
This section contains structured knowledge intended to support interpretation, retrieval, and question answering related to this topic.
For complete understanding, this information should be combined with the documentation on this page. Neither source is intended to stand alone; the page describes the feature, while this section provides additional context that helps disambiguate terminology, intent, applicability, and constraints.
- TL;DR: Configure OAuth 2.0 authentication for a custom channel by defining the token endpoint request, identifying credential fields, extracting the access token from the response, and specifying where to add it to delivery requests.
Intents:
- Configure OAuth 2.0 authentication when creating a custom channel or managing API credentials
- Choose a form or JSON body for the token endpoint request
- Identify credential fields in headers, query parameters, and request bodies
- Extract an access token from a top-level or nested response field
- Add the retrieved token to a delivery request header or query parameter
- Understand token caching and authentication configuration limits
Glossary:
- Token endpoint: The authorization server endpoint that Journey Optimizer calls to retrieve an access token
- Authentication payload: The configuration of the OAuth 2.0 token request, separate from the message payload sent to the delivery endpoint (product-specific)
- Credential paths: The paths identifying request fields that contain credentials, configured through
credentialPaths(product-specific) - Token path: The dot-separated path to the access token in the token endpoint response, configured through
tokenPath(product-specific) - Token location configuration: The delivery request header or query parameter to which the retrieved token is added, configured through
locationConfig(product-specific)
Guardrails:
- Set the authentication configuration
typetooauth2and usepostfor token requests. - The token endpoint must be an absolute HTTPS URL with a non-empty host and a maximum length of 2048 characters.
- Token request bodies support
formandjsonpayloads; choose the format expected by your authorization server. - Credential paths must start with
header,queryParam, orpayload, use dots as separators, and contain no empty path segments. - Form credential paths use the form field key. JSON credential paths use the JSON object path. Do not include
contentor form array indexes in credential paths. - Supported token locations are
headerandqueryParam. - The token endpoint timeout must be between 300 and 60000 milliseconds.
- When token caching is enabled, the cache duration must be between 300 and 3600 seconds. Journey Optimizer reuses the token for the configured duration instead of retrieving a token for every delivery request.
- Credential values must contain between 1 and 1024 characters.
- An empty
tokenPathis allowed only when the entire response is the token.
Terminology:
- Canonical name: OAuth 2.0 authentication - variants: OAuth 2.0 authentication payload, OAuth token request configuration
- Do not confuse: “authentication payload” (configuration for retrieving an access token) with “message payload” (content sent to the custom channel delivery endpoint)
- Do not confuse:
credentialPaths(credential fields in the token request) withtokenPath(access token field in the token response) - Do not confuse:
request.headersandrequest.queryParams(values sent to the token endpoint) withlocationConfig(where the retrieved token is added to delivery requests)
FAQ:
- Q: When should I use a form or JSON payload? - Use
formwhen the token endpoint expects form fields, andjsonwhen it expects a JSON request body. - Q: How do I identify a client secret in a form body? - Use the form field key, for example,
payload.client_secret, withoutcontentor an array index. - Q: How do I identify credentials in a nested JSON body? - Use dot notation, for example,
payload.credentials.client_secret. - Q: How do I extract a token from a nested response? - Set
tokenPathto the response field path, for example,data.access_token. - Q: Where can Journey Optimizer add the token to delivery requests? - Set
locationConfig.locationtoheaderorqueryParamandlocationConfig.keyto the header or query parameter name. - Q: Does Journey Optimizer retrieve a token for every delivery request? - When caching is enabled, it reuses the token for the configured cache duration.