OAuth 2 (client credentials) authentication
Introduction
When a user chooses to add a connector instance using OAuth 2 (client credentials) authentication, they are required to enter the following credentials:
Credential | Notes |
---|---|
| Generated in Netsuite as part of your initial Patchworks integration. For more information see Stage 1: Gather NetSuite credentials. |
| This is always the first element of the URL that you can see having logged into NetSuite. For more information see Stage 1: Gather NetSuite credentials. Note that this value is case sensitive and must be entered exactly as it shows in your NetSuite URL. For example, in NetSuite where the account ID is |
| Paste in the entire contents of the private key ( |
| Paste in the certificate id associated with the certificate file ( |
If you are using a custom version of our prebuilt NetSuite connector (i.e. if authentication method and/or endpoint settings have been updated after the original installation), please be aware that your settings and requirements may vary.
Setting up OAuth 2 (client credentials) authentication
In order to add connector instances for NetSuite using OAuth 2 (client credentials) authentication, you must have completed all generic setup detailed in our Preparing your NetSuite environment to work with Patchworks guide.
Then, please complete the steps detailed in the following sections to enable OAuth 2 (client credentials) authentication:
Stage 1: Gather NetSuite credentials
Consumer key
If you have followed our Preparing your NetSuite environment to work with Patchworks guide, you will have added a Patchworks integration and saved your client credentials (consumer key
/client id
and consumer secret
/client secret
) to a password manager. Make sure that you have these to hand.
If you can't find these credentials, you can generate a new set.
Be aware that if you reset credentials that have already been used to configure Patchworks connector instances, process flows will fail until you apply the new credentials.
Account ID
This is always the first element of the URL that you can see having logged into NetSuite. For example, with the following URL:
https://tstdrv1431250.app.netsuite.com/app/center/card.nl?sc=-29&whence=
...the account id would be:
tstdrv1431250
Stage 2: Create a certificate
Follow the steps below:
Step 1 From a command line or terminal window, use the command below to generate a certificate:
Step 2 You'll be prompted to enter information such as company name, email, etc. Complete each prompt as appropriate and press Enter.
Step 3 Two files will be generated:
auth-cert.pem
auth-key.pem
For more information about certificate requirements in NetSuite, please see the following NetSuite article:
Stage 3: Upload certificate to NetSuite
Follow the steps below:
Step 1 Log into NetSuite as an admin user.
Step 2 Navigate to setup > integration > OAuth 2.0 Client Credentials (M2M) Setup:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252FEXYpOeDX3jUxgp0QGFL2%252Fintegration%2520settings%25201.png%3Falt%3Dmedia%26token%3D459cd47e-67e6-4965-b025-25d80a967d20&width=768&dpr=4&quality=100&sign=36543154&sv=1)
Step 3 Click the create new button:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252Frftnwk3729I6GzMuNe0k%252Fupload%2520cert%25201.png%3Falt%3Dmedia%26token%3Db8aca383-fb86-4130-ace5-ad5b71692a00&width=768&dpr=4&quality=100&sign=b023d7cd&sv=1)
...the create a new credentials mapping page is displayed:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252FCbSXfyk0lULG398FrFaa%252Fupload%2520cert%25202.png%3Falt%3Dmedia%26token%3D2956f435-a965-45cc-9bd5-2050624e5efe&width=768&dpr=4&quality=100&sign=e4bdcf0b&sv=1)
Step 4 Select your name (or a preferred alternative) from the entity dropdown field, followed by the role (this should be administrator) and finally the application (the name of your Patchworks integration).
Step 5 Click the choose a file button:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252F0ZJJZAN0e968gBh9HttW%252Fupload%2520cert%25203.png%3Falt%3Dmedia%26token%3D0a3bb434-14bb-4d2b-a834-49957bef1199&width=768&dpr=4&quality=100&sign=7fc04942&sv=1)
Step 6 Upload the auth-cert.pem file that you generated in Stage 1:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252FngrdO88OVC2YtqylOe3Z%252Fupload%2520cert%25204.png%3Falt%3Dmedia%26token%3D0f6eef3b-f14f-4c88-81d1-b13096d21392&width=768&dpr=4&quality=100&sign=50c361cb&sv=1)
Step 7 Add the certificate id to your password manager - you'll need this to add connector instances for NetSuite later:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252FkA1sWSEDr5aAIVCecqP3%252Fupload%2520cert%25205.png%3Falt%3Dmedia%26token%3D95e9fa78-f9b8-424e-a74a-ef1b9e2fc799&width=768&dpr=4&quality=100&sign=a3ec1b98&sv=1)
Stage 4: Add/install a custom script
We've added the required to our script marketplace, so you can download it directly from there if preferred. To do this, select scripts from the left-hand navigation bar, then install the Netsuite Prereq Oauth2 CC script:
Having done this, you can go straight to Stage 5.
Follow the steps below if you want to create the script manually:
Step 1 Log into the Patchworks dashboard and select scripts from the left-hand navigation menu.
Step 2 Click the create script button:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252FSsd3P1jHnvQB3hxGaLnE%252Fcreate%2520script%25201.png%3Falt%3Dmedia%26token%3Dcbe15a7c-eb1f-49b6-a6da-22e2ffc460b5&width=768&dpr=4&quality=100&sign=8e3c0c45&sv=1)
Step 3 In the name field, type the following:
Step 4 In the description field, type the following:
Step 5 Click in the language field and select JavaScript:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252FLnPfOqSB49lqeWICkf3I%252Fcreate%2520script%25202.png%3Falt%3Dmedia%26token%3Dcc618736-517f-4407-9751-3a5f4f209d67&width=768&dpr=4&quality=100&sign=fd21782e&sv=1)
Step 6 Click the create button.
Step 7 The script is created and opened in edit mode - select and remove any placeholder code:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252FXr6PTPYU7VieOgHXWqBH%252Fcreate%2520script%25203.png%3Falt%3Dmedia%26token%3Deb1fa822-9900-4ff8-90a6-e1201ba90b57&width=768&dpr=4&quality=100&sign=a80a6922&sv=1)
Step 8 Paste in the code below.
Step 9 Click the save and deploy button:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252F4OzJaWWnpi5a7cxwpqoE%252Fcreate%2520script%25204.png%3Falt%3Dmedia%26token%3D2414a0f5-5856-409d-b2af-51995908e6bf&width=768&dpr=4&quality=100&sign=2b2f1d59&sv=1)
Stage 5: Apply the pre-request script
Step 1 From the Patchworks dashboard, select connectors and instances from the left-hand navigation menu to access your installed connectors.
Step 2 If the NetSuite connector is not already installed, install it now.
Step 3 Find your NetSuite connector and click the settings icon:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252FfJwxWF4I9SL9JILnWoer%252Fapply%2520script%25201.png%3Falt%3Dmedia%26token%3D0a8324da-0dfe-4221-bf91-98c4bf71ffd3&width=768&dpr=4&quality=100&sign=e4a2a407&sv=1)
Step 4 Click the authentication option:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252FXaq5omKKNkRJH0s0eg7M%252Fapply%2520script%25202.png%3Falt%3Dmedia%26token%3D70560c1a-854a-439e-b4c1-ed20ab31997c&width=768&dpr=4&quality=100&sign=a4c982ff&sv=1)
Step 5 Select the Netsuite OAuth2 Auth Client Credentials authentication method.
Step 6 Select the pre-request script tab:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252Fm5IF9Py0eIpRiA0vbQ4M%252Fapply%2520script%25203.png%3Falt%3Dmedia%26token%3Dec1cf1ce-bc4c-45b9-91be-c4f467ff7bc4&width=768&dpr=4&quality=100&sign=9c3199aa&sv=1)
Step 7 Click in the select script field and select your NetSuite OAuth 2 - Generate Client Assertion script::
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252FxBGLNZghrSPSZJxFEZyG%252Fapply%2520script%25204.png%3Falt%3Dmedia%26token%3D5b70bb43-8441-4a4b-abce-59ad67369685&width=768&dpr=4&quality=100&sign=f93ca01a&sv=1)
Step 8 Select the latest version:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252FEL7DGUmHNyO1mrZ7VZbw%252Fapply%2520script%25205.png%3Falt%3Dmedia%26token%3D3e9f11c9-fd9e-4919-8499-9337c69711d1&width=768&dpr=4&quality=100&sign=9ab5ce5a&sv=1)
Step 9 Save changes:
![](https://doc.wearepatchworks.com/~gitbook/image?url=https%3A%2F%2F2440044887-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYNcUBVQwSkOMG6KjZfz%252Fuploads%252FiIYVJ9Q6OCShjfP0PDKB%252Fapply%2520script%25206.png%3Falt%3Dmedia%26token%3D7e9e3bcf-4041-4e5b-9246-7e71474ee8d7&width=768&dpr=4&quality=100&sign=bd2dac0b&sv=1)
Step 10 You can now add connector instances for NetSuite using OAuth 2 (client credentials) authentication.
Last updated