STUDIO Visual Editor
-
If you haven’t already done so, create a new Mule project.
-
Click the Global Elements tab at the bottom of the canvas.
-
Click on Create to create a new global element, then expand the Cloud Connectors node and select the appropriate global type that matches your OAuth-enabled connector.
-
Complete the Consumer Key and Consumer Secret with the information that the service provider gave you.
-
On the OAuth tab, enter the callback URL.
Field
Example
CloudHub
Domain
localhost
${fullDomain}
The domain of the endpoint where your OAuth callback is hosted. When in production, this will be the domain where your application is hosted.
Local Port
8081
${http.port}
The port which your authorization flow is hosted on. This will be the port which your HTTP endpoint is hosted on.
Remote Port
${fullDomain}
The port of the endpoint where your OAuth callback is hosted.
Path
callback
callback
The path of the endpoint where your OAuth callback is hosted.
What you place in these parameters will be used to construct the full callback URL in the following form:
http://[domain]:[remotePort]/[path]
. The example above results in a callback URL ofhttp://localhost:8081/callback
.
Controlling Flow Processing
You can decide what happens when a connector is invoked by a user that has no OAuth token set for the connector (i.e. he is not yet authenticated via OAuth). There are two options:
-
STOP_FLOW: acts as a filter and kills the execution of the flow.
-
EXCEPTION: throws an exception informing that the token is not acquired.
EXCEPTION is the default value of this parameter. If you want to keep error logs light, STOP_FLOW is probably the ideal choice as it doesn’t create exceptions before you have had a chance to authorize your connector to access the OAuth provider.
XML Editor or Standalone
Configure a connector as shown in the following example:
<sfdc:config-with-oauth name="salesforce" consumerKey="[insert key]" consumerSecret="[insert secret]" doc:name="Salesforce (OAuth)">
<sfdc:oauth-callback-config domain="localhost" remotePort="8081" path="callback"/>
</sfdc:config-with-oauth>
The Callback URL
The oauth-callback-config
element instructs the connector and the OAuth provider what the callback URL should be. Here are the different parameters that can be set on this element:
Field |
Example |
CloudHub |
|
Domain |
|
|
The domain of the endpoint where your OAuth callback is hosted. When in production, this will be the domain where your application is hosted. |
Local Port |
|
The port which your authorization flow is hosted on. This will be the port which your HTTP endpoint is hosted on. |
|
Remote Port |
|
|
The port of the endpoint where your OAuth callback is hosted. |
Path |
|
|
The path of the endpoint where your OAuth callback is hosted. |
What you place in these parameters will be used to construct the full callback URL in the following form: http://[domain]:[remotePort]/[path]
. The example above results in a callback URL of` http://localhost:8081/callback`.
Controlling Flow Processing
You can decide what happens when a connector is invoked by a user that has no OAuth token set for the connector (i.e. he is not yet authenticated via OAuth). The onNoToken
parameter can be used to set this, it has two possible values:
-
STOP_FLOW
: acts as a filter and kills the execution of the flow. -
EXCEPTION
: throws an exception informing that the token is still not acquired.
EXCEPTION
is the default value of this parameter. If you want to keep error logs light, STOP_FLOW
is probably the ideal choice as it doesn’t create exceptions before you have had a chance to authorize your connector to access the OAuth provider.
<sfdc:config-with-oauth name="salesforce" consumerKey="[insert key]" consumerSecret="[insert secret]" doc:name="Salesforce (OAuth)" onNoToken="[STOP_FLOW|EXCEPTION]">
<sfdc:oauth-callback-config domain="localhost" remotePort="8081" path="callback"/>
</sfdc:config-with-oauth>