Trying to get access_token from an OAuth 2.0 Netsuite instance set with Client Credentials Grant flow but kept getting "unsupported_grant_type".
Have the following successes:
- Postman was able to get access_token to the same OAuth 2.0 Netsuite instance using Authorized Code Grant flow.
- At the suitelet, was able to get the needed signed JWT (const signedJWT); so the RS256 private key .pem file works using the jsrsasign.js module.
At the https.post(), per SuiteAnswers 101107, I have the following header and body:
const postHeaderObj = {host: `${accountID}.suitetalk.api.netsuite.com`, "Content-Type": 'application/x-www-form-urlencoded'};
const grant_type = 'grant_type=client_credentials';
const client_assertion_type = '&client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer';
const client_assertion = `&client_assertion=${signedJWT}`;
const postBodyQueryString = `${grant_type}${client_assertion_type}${client_assertion}`;
const response = https.post({url: href, header: postHeaderObj, body: postBodyQueryString});
const href = `https://${accountID}.suitetalk.api.netsuite.com/services/rest/auth/oauth2/v1/token`
I've tried POST request:
- With/without header; and header with/without host property.
- Body as query string, and as JSON.stringify() object literal.
Question:
- What is the correct https.post() configuration?
- How can I confirm the OAuth 2.0 Netsuite instance (as the Authorization end point) set with Client Credentials Grant flow (enabled in the integration record) has client_credentials set for grant_type (to ensure grant_type supports client_credentials)?