Authentications
Most actions or triggers require user authentication to function. webMethods Integration provides several methods for adding authentication to your actions and triggers.
Basic
If your action or trigger only requires the email ID and password of the user, you can use the basic authentication method. You can customize it with your own code to implement a custom authentication mechanism. For more information, see basic authentication template.
module.exports =
{
label : 'Connect to Demo',
mock_input: {
"username" : "myuser",
"password" : "mypassword"
},
validate : function (input, output)
{
// auth data will be available in input.auth
// var username = input.auth.username
// var password = input.auth.password
// make call to third party api to validate user credentials
// and return callback output(null, true) in case of successful validation
// or return callback output(‘error message’) in case of unsuccessful validation
}
}
OAuth
OAuth is a token-based authentication method that allows the user's account information to be used by any external service to provide secure access, without exposing the password. For example, many websites support multiple login methods. One of the login methods you commonly see is Login through Gmail or Login through Facebook.
webMethods Integration provides built-in OAuth authentication modules for various services. You can either use these built-in modules or create custom OAuth authentication modules based on your requirements.
When selecting the built-in OAuth authentication module for a connector, the OAuth services specific to your tenant will be listed. If no OAuth service is registered, create a custom OAuth module to authenticate using client credentials from an identity provider.
module.exports = {
label : 'Connect to Twitter',
mock_input: { access_token: ‘token’ }, //can be obtained from https://flowoauth.built.io
oauth: 'twitter',
input: {},
validate : function (input, output){
// auth data will be available in input.auth
}
}
You can also create custom OAuth modules to use own credentials for authentication. To do so, run the wmio auth command, select the OAuth authentication method, and then select OAuth 1 or OAuth 2 based on your requirements.
{
"type": "oauth2",
"title": "{{title}}",
"clientId": "<client id="">",
"clientSecret": "<client secret="">",
"authURL": "<authorization url="">",
"tokenURL": "<access token="" url="">",
"preAuthProcessing": {
// any processing or hashing of client_id, client_secret before authorization call
// available processingFunctions uuid, basicAuth, base64, sha256 case-sensitive
},
"authQueryParams": {
// Optional query params required to be in authorization request supports interpolation
},
"preTokenProcessing": {
// any processing or hashing of client_id, client_secret before accessToken call
// available processorApi uuid, basicAuth, base64, sha256 caseSensitive
// eg:
// headers: {
// 'Authorization': 'Basic base64({client_id}{client_secret})'
// }
},
"tokenParams": {
"method": "",
"headers": {},
"data": {
"client_id": "{client_id}",
"client_secret": "{client_secret}",
"redirect_uri": "{redirect_uri}",
"grant_type": "authorization_code"
}
},
"preRefreshProcessing": {
// any processing or hashing of client_id, refresh_token before refreshToken call
},
"refreshParams": {
// add additional keys required for refresh token process
"client_id": "{client_id}",
"client_secret": "{client_secret}",
"redirect_uri": "{redirect_uri}",
"grant_type": "refresh_token"
},
"requiredParams": [
// Optional json schema for rendering form before authorizing
],
"refreshURL": "<refresh token="" url,="" default="" to="" tokenurl="">", //<optional>
"scope": {
//<optional>
"READABLE SCOPE TITLE": "SCOPE"
},
"validate": {
"url": "ANY API URL TO VALIDATE TOKEN OF THIRD PARTY SERVICE",
"headers": {
//<optional>
"Authorization": "Bearer {access_token}"
},
"query": { //<optional>
}
},
"redirectURL": "{{redirectURL}}"
}Once you have created the custom OAuth, you need to deploy it to webMethods Integration. To do so, run the following command:
wmio oauth deploy
API Key
module.exports =
{
label: 'Connect to Demo',
mock_input:
{
"api_key" : "my api key"
},
input: {},
validate: function (input, output)
{
// this function will be executed when running unit test cases and authData will
// be available in input.auth
}
}Custom
module.exports =
{
label : 'Connect to Test',
mock_input: {
"username" : "myuser",
"apikey" : "my api key",
"pass" : "my password"
},
input:
{
type: "object",
properties:
{
//input field definition
}
},
validate : function (input, output)
{
// auth data will be available in input.auth
// var username = input.auth.username
// var password = input.auth.pass
// var apiKey = input.auth.apikey
}
}Noauth
If your action or trigger doesn't require any authentication, you can use the noauth authentication method. This is useful when you are creating or customizing actions such as Logger, JSON Parse (or other utility in-house actions that are provided by webMethods Integration) which do not contain an authentication field.
To implement Noauth for custom connectors:
-
Initiate the command
wmio auth. -
Select the basic auth option.
-
Add the key "auth_type": "noauth" inside your index.json file.
