# mulesoft OAuth Module - Full Documentation --- product: OAuth Module version: 1.1 is-latest-version: true --- # OAuth Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt OAuth Module v1.1 OAuth Module is an extension to hook OAuth2 to HTTP extension connectors. ## Before You Begin To use this module, you must be familiar with: - Anypoint Connectors - Mule runtime engine (Mule) - Elements and global elements in a Mule flow - Creating a Mule app using Anypoint Studio or Anypoint Code Builder ## Using Exchange Templates and Examples [Anypoint Exchange](https://www.mulesoft.com/exchange/) provides templates that you can use as starting points for your apps and examples that illustrate a complete solution. - [OAuth Module in Anypoint Exchange](https://www.mulesoft.com/exchange/org.mule.modules/mule-oauth-module/) ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Exchange to Discover Connectors, Templates, and Examples](https://docs.mulesoft.com/connectors/introduction/intro-use-exchange) - [Salesforce Help](https://help.salesforce.com) --- product: OAuth Module version: 1.1 is-latest-version: true --- # OAuth Module Reference > For the full documentation index, see: https://docs.mulesoft.com/llms.txt OAuth Module v1.1 OAuth Module is an extension to hook OAuth2 to HTTP extension connectors. ## Configurations --- ### Config Default configuration #### Parameters
NameTypeDescriptionDefault ValueRequired

Name

String

Name for this configuration. Connectors reference the configuration with this name.

x

## Operations - [Invalidate Oauth Context](#invalidateOauthContext) - [Retrieve Access Token](#retrieveAccessToken) - [Retrieve Custom Token Response Param](#retrieveCustomTokenResponseParam) - [Retrieve Expires In](#retrieveExpiresIn) - [Retrieve Refresh Token](#retrieveRefreshToken) - [Retrieve State](#retrieveState) ### Invalidate Oauth Context `` Clears the OAuth context for a token manager and a resource owner ID. #### Parameters
NameTypeDescriptionDefault ValueRequired

Token Manager

The token manager that holds the credentials to invalidate..

x

Resource Owner Id

String

The resource owner ID to invalidate. This attribute is allowed only for authorization code grant type.

default

### Retrieve Access Token `` Returns the access token of the token manager for the parametrized resource owner ID. #### Parameters
NameTypeDescriptionDefault ValueRequired

Token Manager

The token manager that holds the access token.

x

Resource Owner Id

String

The resource owner ID to invalidate. This attribute is allowed only for authorization code grant type.

default

Output Mime Type

String

The MIME type of the payload that this operation outputs.

Target Variable

String

Name of the variable that stores the operation’s output.

Target Value

String

Expression that evaluates the operation’s output. The expression outcome is stored in the Target Variable.

#[payload]

#### Output

Type

String

### Retrieve Custom Token Response Param `` Returns the value of the parameter that is extracted during the OAuth dance from the token manager for the parametrized resource owner ID. #### Parameters
NameTypeDescriptionDefault ValueRequired

Token Manager

The token manager that holds the access token.

x

Resource Owner Id

String

The resource owner ID to invalidate. This attribute is allowed for authorization code grant type.

default

Key

String

A key to look in the elements that are extracted after the OAuth dance.

x

Output Mime Type

String

The MIME type of the payload that this operation outputs.

Target Variable

String

Name of the variable that stores the operation’s output.

Target Value

String

Expression that evaluates the operation’s output. The expression outcome is stored in the Target Variable.

#[payload]

#### Output

Type

String

### Retrieve Expires In `` Returns the expiration of the OAuth context for the parametrized resource owner ID. #### Parameters
NameTypeDescriptionDefault ValueRequired

Token Manager

The token manager that holds the access token.

x

Resource Owner Id

String

The resource owner ID to invalidate. This attribute is allowed for authorization code grant type.

default

Output Mime Type

String

The MIME type of the payload that this operation outputs.

Target Variable

String

Name of the variable that stores the operation’s output.

Target Value

String

Expression that evaluates the operation’s output. The expression outcome is stored in the Target Variable.

#[payload]

#### Output

Type

String

### Retrieve Refresh Token `` Returns the refresh token of the OAuth context for the parametrized resource owner ID. #### Parameters
NameTypeDescriptionDefault ValueRequired

Token Manager

The token manager that holds the refresh token.

x

Resource Owner Id

String

The resource owner ID to invalidate. This attribute is allowed for authorization code grant type.

default

Output Mime Type

String

The mime type of the payload that this operation outputs.

Target Variable

String

Name of the variable that stores the operation’s output.

Target Value

String

Expression that evaluates the operation’s output. The expression outcome is stored in the Target Variable.

#[payload]

#### Output

Type

String

### Retrieve State `` Returns the state of the OAuth context for the parametrized resource owner ID. #### Parameters
NameTypeDescriptionDefault ValueRequired

Token Manager

The token manager that holds the access token.

x

Resource Owner Id

String

The resource owner ID to invalidate. This attribute is allowed for authorization code grant type.

default

Output Mime Type

String

The MIME type of the payload that this operation outputs.

Target Variable

String

Name of the variable that stores the operation’s output.

Target Value

String

Expression that evaluates the operation’s output. The expression outcome is stored in the Target Variable.

#[payload]

#### Output

Type

String

## Types ### Token Manager Config
FieldTypeDescriptionDefault ValueRequired

Object Store

Object Store

An object store to store the OAuth context data.

### Authorization Code Grant Type
FieldTypeDescriptionDefault ValueRequired

Local Callback Config

String

Listener configuration to use instead of localCallbackUrl. Note that if using this configuration you must also provide a localCallbackConfigPath separately.

Local Callback Config Path

String

Local path for the listener created according to localCallbackConfig, not required if you use localCallbackUrl.

Local Callback Url

String

URL that enables Mule runtime engine (Mule) to automatically create an endpoint in the configured URL that stores the authentication code unless there is an endpoint already registered to manually extract the authorization code.

External Callback Url

String

The OAuth authentication server uses the URL to provide the authentication code to the Mule server in order to retrieve the access token. Note that the URL must be the externally visible address of the callback, not the local address.

x

State

String

State parameter for holding state between the authentication request and the callback done by the OAuth authorization server to the redirectUrl.

Local Authorization Url Resource Owner Id

String

Identifier to store the OAuth authentication attributes (accessToken, refreshToken, etc). This attribute is required only when applications access resources from more than one user in the OAuth authentication server.

Local Authorization Url

String

URL that enables Mule to automatically create an endpoint in the host server for the user to authenticate and grant access to the application for their account.

x

Authorization Url

String

The OAuth authentication server URL to authorize the app for a certain user.

x

Custom Parameters

Object

Custom parameters to send to the authorization request URL or the OAuth authorization sever.

Resource Owner Id

String

Identifier to store the OAuth authentication attributes (accessToken, refreshToken, etc). This attribute is required only when applications access resources from more than one user in the OAuth authentication server.

default

Encode Client Credentials In Body

Boolean

If true, the client ID and client secret are sent in the request body. Otherwise, the client ID and client secret are sent as basic authentication.

true

Client Id

String

Application identifier defined in the OAuth authentication server.

x

Client Secret

String

Application secret defined in the OAuth authentication server.

x

Scopes

String

Scope required by the application to execute. Scopes define permissions over resources.

Token Manager

The token manager configuration to use for the grant type.

Token Url

String

The OAuth authentication server URL to get access to the token. Mule calls this URL to get the access token, after receiving the authentication code from the OAuth server through the redirectUrl.

x

Response Access Token

String

Expression to extract the access token parameter from the response of the call to tokenUrl.

#[payload.access_token]

Response Refresh Token

String

Response refresh token.

#[payload.refresh_token]

Response Expires In

String

Expression to extract the expires in parameter from the response of the call to tokenUrl.

#[payload.expires_in]

Custom Parameter Extractors

Refresh Token When

Boolean

Enables expressions to evaluate against the HTTP response of the API callback to determine if the request failed because it was done using an expired token. If the evaluation returns true (access token expired), Mule automatically triggers a refresh token flow and retries the API callback using a new access token. Default value evaluates if the response status code is 401 or 403.

#[attributes.statusCode == 401 or attributes.statusCode == 403]

Tls Context

A TLS configuration to receive incoming HTTP requests and do HTTP requests during the OAuth dance.

### Parameter Extractor
FieldTypeDescriptionDefault ValueRequired

Param Name

String

Parameter extractor name.

x

Value

String

Value for this type.

x

### TLS Configures TLS to provide secure communications for the Mule app.
FieldTypeDescriptionDefault ValueRequired

Enabled Protocols

String

Comma-separated list of protocols enabled for this context.

Enabled Cipher Suites

String

Comma-separated list of cipher suites enabled for this context.

Trust Store

Configures the TLS truststore.

Key Store

Configures the TLS keystore.

Revocation Check

Revocation check configuration.

### Truststore Configures the truststore for TLS.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the truststore. Mule resolves the path relative to the current classpath and file system.

Password

String

Password used to protect the truststore.

Type

String

Type of store.

Algorithm

String

Encryption algorithm that the truststore uses.

Insecure

Boolean

If true, Mule stops performing certificate validations. Setting this attribute to true make connections vulnerable to attacks.

### Keystore Configures the keystore for the TLS protocol. The keystore you generate contains a private key and a public certificate.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the keystore. Mule resolves the path relative to the current classpath and file system.

Type

String

Type of store.

Alias

String

Alias of the key to use when the keystore contains multiple private keys. By default, Mule uses the first key in the file.

Key Password

String

Password used to protect the private key.

Password

String

Password used to protect the keystore.

Algorithm

String

Encryption algorithm that the keystore uses.

### Standard Revocation Check Configures standard revocation checks for TLS certificates.
FieldTypeDescriptionDefault ValueRequired

Only End Entities

Boolean

Which elements to verify in the certificate chain:

  • true
    Verifies only the last element in the certificate chain.

  • false
    Verifies all the elements in the certificate chain.

Prefer Crls

Boolean

How to check certificate validity:

  • true+ Checks the Certification Revocation List (CRL) for certificate validity.

  • false+

Checks the Online Certificate Status Protocol (OCSP) for certificate validity.

No Fallback

Boolean

Whether to use the secondary method to check certificate validity:

  • true

Uses the method not specified in the Prefer Crls field to check the certificate validity.

  • false

Does not use the method specified in the Prefer Crls field to check certificate validity.

Soft Fail

Boolean

What to do if the revocation server can’t be reached or is busy:

  • true

Avoids verification failure.

  • false

Enables the verification to fail.

### Custom OCSP Responder Configures a custom OCSP responder for certification revocation checks.
FieldTypeDescriptionDefault ValueRequired

Url

String

URL of the OCSP responder.

Cert Alias

String

Alias of the signing certificate for the OCSP response. If specified, the alias must be configured in the truststore.

### CRL File Specifies the location of the certification revocation list (CRL) file.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the CRL file.

### Client Credentials Grant Type
FieldTypeDescriptionDefault ValueRequired

Encode Client Credentials In Body

Boolean

If true, the client ID and client secret are sent in the request body. Otherwise, the client ID and client secret are sent as basic authentication.

false

Client Id

String

Application identifier defined in the OAuth authentication server.

x

Client Secret

String

Application secret defined in the OAuth authentication server.

x

Scopes

String

Scope required by the application to execute. Scopes define permissions over resources.

Token Manager

The token manager configuration to use for the grant type.

Token Url

String

The OAuth authentication server URL to get access to the token. Mule calls this URL to get the access token, after receiving the authentication code from the OAuth server through the redirectUrl.

x

Response Access Token

String

Expression to extract the access token parameter from the response of the call to tokenUrl.

#[payload.access_token]

Response Refresh Token

String

Response refresh token.

#[payload.refresh_token]

Response Expires In

String

Expression to extract the expires in parameter from the response of the call to tokenUrl.

#[payload.expires_in]

Custom Parameter Extractors

Custom parameter extractors configuration.

Refresh Token When

Boolean

Enables expressions to evaluate against the HTTP response of the API callback to determine if the request failed because it was done using an expired token. If the evaluation returns true (access token expired), Mule automatically triggers a refresh token flow and retries the API callback using a new access token. Default value evaluates if the response status code is 401 or 403.

#[attributes.statusCode == 401 or attributes.statusCode == 403]

TLS Context

A TLS configuration to receive incoming HTTP requests and do HTTP requests during the OAuth dance.

## See Also - [Salesforce Help](https://help.salesforce.com) --- product: OAuth Module version: 1.1 is-latest-version: true --- # OAuth Module XML and Maven Support > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Studio. If you manually code a Mule runtime engine (Mule) app in XML, either from the Anypoint Studio XML editor or from a text editor, you can get access to the connector in your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. When you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location. It also adds a dependency to the `pom.xml` file. ## Add a Namespace for the Connector Paste the following code inside the `` tag of the header of your configuration XML: ```xml http://www.mulesoft.org/schema/mule/oauth http://www.mulesoft.org/schema/mule/oauth/current/mule-oauth.xsd ``` This example shows how the namespace statements are placed in the `` XML block: ```xml ``` ## Add a POM File Dependency The Apache Maven `pom.xml` file generated by Anypoint Studio contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml org.mule.modules mule-oauth-module x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for `oauth module`. 4. Select the connector. 5. Click **Dependency Snippets** near the upper right of the screen. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: OAuth Module version: 1.1 is-latest-version: true --- # Troubleshooting OAuth Module > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To troubleshoot OAuth module, become familiar with the information about enabling verbose logging and interpreting commonly throw messages. ## Enable Verbose Logging To get a better understanding of why an application’s interaction with OAuth module is failing, temporarily enable verbose logging for the module. Remember to always disable the enhanced verbosity after troubleshooting, because it affects your Mule application performance. To enable verbose logging in the configuration file: 1. Access Anypoint Studio and navigate to the **Package Explorer** view. 2. Open your application’s project name. 3. Open the `src/main/resources` folder. 4. Open the `log4j2.xml` file inside the folder. 5. Add an `` tag inside the `` tag: ```xml ... ... ``` 6. Save your application changes. 7. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. ## Understand Common Throws Here is a list of common thrown messages and how to interpret them: - HTTP:SECURITY Occurs when there is an error related to an HTTP request. ## See Also - [Salesforce Help](https://help.salesforce.com) - [Known Issues](https://help.salesforce.com/s/issues)