Configurare l’autenticazione OAuth 2.0 custom-channel-oauth2

In questa pagina: scopri come configurare l’autenticazione OAuth 2.0 per i canali personalizzati in Adobe Journey Optimizer, incluso il payload della richiesta del token, i percorsi delle credenziali, l’estrazione del token e la posizione del token nelle richieste di consegna.

Quando selezioni OAuth 2.0 come tipo di autenticazione durante la creazione di un canale personalizzato, configura la richiesta di token utilizzata da Adobe Journey Optimizer per recuperare un token di accesso dal server autorizzazioni.

Journey Optimizer invia la richiesta del token utilizzando la configurazione endpoint, method, request e policy. Estrae quindi il token di accesso dalla risposta utilizzando tokenPath e lo aggiunge alla richiesta di consegna utilizzando locationConfig.

Il payload di autenticazione OAuth 2.0 configura la richiesta all’endpoint token. È separato dal payload del messaggio inviato all’endpoint di consegna del canale personalizzato.

Configurare la richiesta di token token-request

Utilizza gli esempi seguenti per configurare la richiesta di token. Sostituire l’endpoint di esempio e i valori delle credenziali con quelli richiesti dal server autorizzazioni. Le voci headers e queryParams negli esempi sono facoltative: rimuoverle se l’endpoint token non le richiede e rimuovere le voci corrispondenti da credentialPaths.

Esempio di corpo del modulo form-body-example

Utilizzare un payload form quando l’endpoint token prevede campi modulo come grant_type, client_id o client_secret.

{
  "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"
  }
}

Per un payload form, ogni percorso delle credenziali utilizza la chiave del campo modulo, ad esempio payload.client_secret. Non includere content o indici di array nel percorso delle credenziali.

Esempio di corpo JSON json-body-example

Utilizza un payload json quando l’endpoint token richiede un corpo di richiesta 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"
  }
}

Campi OAuth 2.0 oauth2-fields

Campo
Descrizione
type
Deve essere oauth2.
endpoint.uri
URL HTTPS dell’endpoint token OAuth 2.0.
method
Metodo HTTP utilizzato per chiamare l’endpoint del token. Utilizza post per le richieste di token.
request.headers
Intestazioni facoltative inviate all’endpoint del token.
request.queryParams
Parametri di query facoltativi aggiunti all’URL dell’endpoint del token.
request.payload
Corpo della richiesta token. Supporta form e json payload.
request.payload.includeNullValues
Definisce se i campi con un valore null vengono inclusi nel corpo della richiesta del token.
response.type
Formato di risposta. Utilizzare json quando l’endpoint token restituisce una risposta JSON.
policy.timeoutInMilliseconds
Tempo massimo di attesa della risposta dell’endpoint del token.
policy.cache
Definisce se il token OAuth è memorizzato nella cache e per quanto tempo.
policy.retry
Configurazione facoltativa dei tentativi per errori dell’endpoint del token.
credentialPaths
Percorsi per la richiesta di campi che contengono credenziali. Questi campi vengono trattati come credenziali e possono essere gestiti in modo sicuro.
tokenPath
Percorso separato da punti del token di accesso nella risposta OAuth, ad esempio access_token o data.access_token.
locationConfig
Definisce dove viene aggiunto il token recuperato alla richiesta di consegna.
locationConfig.key
Nome dell’intestazione o del parametro di query che contiene il token, ad esempio Authorization.
locationConfig.location
Dove viene aggiunto il token: header o queryParam.

Quando il caching dei token è abilitato, Journey Optimizer riutilizza il token OAuth per la durata della cache configurata invece di chiamare l’endpoint del token per ogni richiesta di consegna.

Identificare i campi delle credenziali credential-paths

Utilizzare credentialPaths per identificare quali campi di richiesta contengono le credenziali. Se un’intestazione o un parametro di query contiene una credenziale, includi il relativo percorso così come eventuali percorsi delle credenziali nel corpo della richiesta. Gli esempi riportati sopra identificano i valori di intestazione di esempio e dei parametri di query come credenziali. Modificare l’elenco in modo che corrisponda alla richiesta.

Prefisso
Utilizzato per
Esempio
header.
Credenziali passate nelle intestazioni di richiesta.
header.sampleHeaderKey
queryParam.
Credenziali passate nei parametri di query.
queryParam.sampleQueryParamKey
payload.
Credenziali passate nel corpo della richiesta.
payload.client_secret

Applica le seguenti regole:

  • I percorsi devono iniziare con header, queryParam o payload e utilizzare i punti come separatori.
  • Per i payload form, utilizzare payload.<formFieldKey>.
  • Per i payload json, utilizzare il percorso dell’oggetto JSON, ad esempio payload.client_id o payload.credentials.client_secret. Non includere content nel percorso.
  • I segmenti di percorso vuoti non sono supportati. payload..client_id, ad esempio, non è valido.

Per un corpo JSON nidificato, utilizza la notazione del punto come mostrato in questo estratto di configurazione:

{
  "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"
  ]
}

Estrarre il token di accesso token-path

tokenPath definisce dove si trova il token di accesso nella risposta del token OAuth 2.0.

Per la risposta seguente, impostare tokenPath su access_token:

{
  "access_token": "example-access-token",
  "token_type": "Bearer",
  "expires_in": 3600
}

Per una risposta nidificata, impostare tokenPath su data.access_token:

{
  "data": {
    "access_token": "example-access-token"
  }
}

Aggiungere il token alle richieste di consegna token-location

locationConfig definisce dove Journey Optimizer aggiunge il token recuperato quando chiama l’endpoint di consegna del canale personalizzato.

Per inviare il token nell’intestazione Authorization, utilizzare:

{
  "locationConfig": {
    "key": "Authorization",
    "location": "header"
  }
}
Posizione
Descrizione
header
Aggiunge il token come intestazione HTTP.
queryParam
Aggiunge il token come parametro di query.

Limiti e regole di convalida limits

Campo
Limite
endpoint.uri
Deve essere un URL HTTPS assoluto con un host non vuoto. Lunghezza massima: 2048 caratteri.
policy.timeoutInMilliseconds
Minimo: 300 ms. Massimo: 60000 ms.
policy.cache.ttlInSeconds
Applicabile quando la cache è abilitata. Minimo: 300 secondi. Massimo: 3600 secondi.
request.headers
Massimo 50 intestazioni. Lunghezza chiave intestazione: 1-100 caratteri. Valore intestazione massimo: 8192 caratteri.
request.queryParams
Massimo 50 parametri di query. Lunghezza chiave del parametro di query: 1-100 caratteri. Massimo valore parametro query: 8192 caratteri.
request.payload.type=form
Massimo 50 campi modulo. Lunghezza chiave modulo: 1-100 caratteri. Le chiavi di modulo duplicate non sono consentite.
Valori delle credenziali
1-1024 caratteri.
tokenPath
Deve essere un percorso valido separato da punti. Un valore vuoto è consentito solo quando l’intera risposta è il token.
credentialPaths
Deve iniziare con header, queryParam o payload e utilizzare i punti come separatori.

Passaggi successivi next-steps

AI Knowledge Reference

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 type to oauth2 and use post for 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 form and json payloads; choose the format expected by your authorization server.
  • Credential paths must start with header, queryParam, or payload, 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 content or form array indexes in credential paths.
  • Supported token locations are header and queryParam.
  • 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 tokenPath is 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) with tokenPath (access token field in the token response)
  • Do not confuse: request.headers and request.queryParams (values sent to the token endpoint) with locationConfig (where the retrieved token is added to delivery requests)

FAQ:

  • Q: When should I use a form or JSON payload? - Use form when the token endpoint expects form fields, and json when 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, without content or 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 tokenPath to the response field path, for example, data.access_token.
  • Q: Where can Journey Optimizer add the token to delivery requests? - Set locationConfig.location to header or queryParam and locationConfig.key to 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.
recommendation-more-help
journey-optimizer-help