Step One GET Request to the Authorization Endpoint
In the first step of the OAuth 2.0 authorization code grant flow, the application sends a GET request to the authorization endpoint. This request must include the required parameters in the request header.
The format of the URL is:
https://<accountID>.app.netsuite.com/app/login/oauth2/authorize.nl
.
where <accountID> represents your NetSuite account ID. If you do not know the specific account ID, requests can be sent to
https://system.netsuite.com/app/login/oauth2/authorize.nl
.
See the following table for details about parameters for the GET request.
Request Parameters for Step One
Request Parameter |
Description |
---|---|
response_type |
The value of the response_type parameter is always |
client_id |
|
redirect_uri |
|
scope |
Note:
NetSuite supports two additional scopes that are used for the NetSuite as OIDC Provider feature. For more information, see Step One GET Request to the Authorization Endpoint in the NetSuite as OIDC Provider topic. |
state |
The length of the state parameter must be between 22 and 1024 characters. Valid characters are all printable ASCII characters. The value of the state parameter must be unique for each authorization flow.
Important:
To avoid cross-site request forgery (CSRF) attacks, you must conform to the OAuth 2.0 specification. For more information, see RFC6749 Section 10.12. |
code_challenge |
|
code_challenge_method |
Important:
As of 2020.2, NetSuite does not support a value of |
prompt |
The optional prompt parameter provides additional control of when the consent screen appears. Following are the values you can use with the prompt parameter:
For more information, see Integration Record and Prompt Parameter Combinations. |
Request parameters must be encoded based on the HTML specification for the application/x-www-form-urlencoded
media type. For more information, see URL Specification 5.1.
The following URL provides a sample GET request.
https://<accountID>.app.netsuite.com/app/login/oauth2/authorize.nl?scope=restlets+rest_webservices&redirect_uri=https%3A%2F%2Fmyapplication.com%2Fnetsuite%2Foauth2callback&response_type=code&client_id=6794a3086e4f61a120350d01b8527aed3631472ef33412212495be65a8fc8d4c&state=ykv2XLx1BpT5Q0F3MRPHb94j&code_challenge=Who5QBshz2Mu1Mq6GuAknYA5TnjA-0z7VhAgLloec1s&code_challenge_method=S256
Consent Screen
After the application sends the GET request, the system displays the consent screen, where a user authorizes the application to access NetSuite through RESTlets, REST web services, or SuiteAnalytics Connect.
If there is no active NetSuite session, the user is first redirected to the NetSuite login form. If the GET request points to an account-specific domain, for an account with SAML SSO or OIDC enabled, the user may be redirected to a third party application. After successful authentication, the system displays the consent screen.
The consent screen includes the following:
-
The Application Logo, Terms of Use, and Privacy Policy, if these values were entered in the integration record.
-
A data and a role to which the application requests access.
-
The Allow/Continue button. If the application was not previously authorized, the user must click Allow to authorize the application. If the application was previously authorized, the user must click a Continue button to continue to the next step of the flow.
-
The Deny/Go Back button. If the application was not previously authorized, the user can click Deny to interrupt the flow. If the application was previously authorized, the user can click Go Back to interrupt the flow.
-
The Choose Another Role list. The user can change a role that authorizes the application, by clicking the Choose Another Role link.
Redirect Parameters for Step One
After authorization, NetSuite initiates a redirect to the Redirect URI, with the following parameters:
Redirect Parameter |
Description |
---|---|
state |
The state parameter in the redirect matches the state parameter in the request in Step One. |
code |
|
role |
Indicates the user’s role for which the access token and refresh token are granted in Step Two. The role parameter is a NetSuite-specific parameter. |
entity |
The ID of the user who authorizes the application or interrupts the flow. The entity parameter is a NetSuite-specific parameter. |
company |
NetSuite account ID (company identifier). The company parameter is a NetSuite-specific parameter. |
error |
The error parameter is only used when an error occurs during the flow. For information about error values, see Troubleshooting OAuth 2.0. |
The following sample redirects illustrate successful and unsuccessful authorization.
-
Application successfully authorized:
https://myapplication.com/netsuite/oauth2callback?state=ykv2XLx1BpT5Q0F3MRPHb94j&role=1000&entity=12&company=1234567&code=70b827f926a512f098b1289f0991abe3c767947a43498c2e2f80ed5aef6a5c50
-
Application not authorized:
https://myapplication.com/netsuite/oauth2callback?state=ykv2XLx1BpT5Q0F3MRPHb94j&role=1000&entity=12&company=1234567&error=access_denied
After the request to the redirect URI is sent, the flow proceeds to Step Two POST Request to the Token Endpoint.