Steps to setup OAuth 2.0

  1. Enable the OAuth 2.0 Feature

2. Set Up OAuth 2.0 Roles

3. Assign Users to OAuth 2.0 Roles

4. Create Integration Records for Applications to Use OAuth 2.0

From the Integration record, we get ClientID and Client secret

Then In Postman

Step 1 GET Request to the Authorization Endpoint

The following URL provides a sample GET request

https://<accountID>.netsuite.com/app/login/oauth2/authorize.nl?scope=restlets&redirect_uri=https://www.google.com/&response_type=code&client_id=3010569292123f521732b0a60870e92199481a24c0ac79ba39f35083067e1dee&state=ykv2XLx1BpT5Q0F3MRPHb94j 

Here provide your accountID, redirect_uri, client_id

After sending the get request a consent form will be open like the following. Select the role created from the list. 

Then click the Continue button

NetSuite initiates a redirect to the Redirect URI, and thus we get the CODE

The code has only 10min validity, so access token must create before that

Step 2 POST Request to the Token Endpoint

The application sends a POST request to the token endpoint. The request must include client credentials in the HTTP authorization request header and the necessary parameters in the request body.  

At the end of this step, the access token and refresh token are granted. 

The URL is: https://<accountID>.suitetalk.api.netsuite.com/services/rest/auth/oauth2/v1/token

Authentication: basic Auth

Give the password and username we created

IN Body

code: code we created in step 1

redirect_uri: we provided in the integration record

grant_type:authorization_code

This will return Access Token and Refresh Token

Step 3 Post refresh token for access token

Authentication: basic Auth

Give the password and username we created

In Body

redirect_uri: we provided in integration record

grant_type: refresh_token

refresh_token: we created in step2

This returns an Access Token

This is used in Restlet

Copy the External URL created during script deployment in GET option

Authentication Type: Bearer Token

Token : paste the Access token generated above.

Leave a comment

Your email address will not be published. Required fields are marked *