TBA Authorization Flow ERROR on step 1

Hi,

I’m facing an error on step 1 of “TBA Authorization Flow”. In the login audit trail the error is “MissingRequiredParameter” but already checked that all parameters are ok. I mean, actually it is only a POST request with one header parameter for authorization, here is the header log from axios:

 

_header: ‘POST /rest/requesttoken HTTP/1.1\r\n’ +
‘Accept: application/json, text/plain, */*\r\n’ +
‘Content-Type: application/json;charset=utf-8\r\n’ +
‘Authorization: OAuth realm=”TSTDRV2222222″, oauth_callback=”http%3A%2F%2Flocalhost%3A%2A”, oauth_consumer_key=”c22222222222222222222222222222222222222222222222222222226″, oauth_nonce=”fSB52CCYbuVWtoUBk6ci3rvZXTBv7Upb”, oauth_signature=”%2FxaMWVqkDHo2Y%2BGY98QIpLXG2SjeJQ0%2FUheu0RIx8tw%3D”, oauth_signature_method=”HMAC-SHA256″, oauth_timestamp=”1599683411″, oauth_version=”1.0″\r\n’ +
‘User-Agent: axios/0.20.0\r\n’ +
‘Content-Length: 2\r\n’ +
‘Host: tstdrv2222222.restlets.api.netsuite.com\r\n’ +
‘Connection: close\r\n’ +
‘\r\n’,

 

 

Do you know what may be wrong?

 

Thanks!

Rookie Asked on September 9, 2020 in SuiteTalk.
Add Comment
6 Answer(s)

I believe that you’re missing the oauth_token here. Also, may we confirm if you are using OAuth 2.0 since you have there a oauth_callback

Rookie Answered on September 9, 2020.
Add Comment

Hi,

I don’t think that you need a Token since you’re using OAuth Flow and I have a working sample from Step 1 here:
Authorization: OAuth oauth_consumer_key=”XXXXXXXX”, oauth_nonce=”8744593421646936″, oauth_timestamp=”1599724839″, oauth_signature_method=”HMAC-SHA256″, oauth_callback=”http%3A%2F%2Flocalhost”, oauth_signature=”PWmhTf8dxl5SQ6mHIqyX0flNKiS1WhzLPxfbnQORMDw%3D”

If it’s anything like OAuth 1 then I it may be that it’s being picky about the order of the parameters.

Also note that I’ve not included anything here that isn’t mandatory, like Realm, for example.

Thanks,

Chris

Intermediate Answered on September 10, 2020.
Add Comment

That’s correct, it is OAuth 1.0 and I am at the first step of the flow where I’m trying to get an unathorized token, that is why I’m not sending the oauth_token in this step.

I will play a bit with the order of parameters and taking out the realm to see what happens.

 

Thanks!

Rookie Answered on September 10, 2020.
Add Comment

How about consider including ‘role’ to your parameter?

Authorization: OAuth realm=”1234567″, role=”45678″, oauth_consumer_key=”60712990bc09623786e7047c226bcb3f86d49dca0b04efc21001dc76d97a81f5″, oauth_nonce=”bUvpxBX93OWo0FLswq5M”, oauth_timestamp=”1575998103″, oauth_signature_method=”HMAC-SHA256″, oauth_version=”1.0″, oauth_callback=”https%3A%2F%2Fmy.example.com%2FTBA%2F%3FcallbackRequest”, oauth_signature=”7kgwwmiAylqeMdHjCBnIUUW%2BdrDrGCbZGBkuCt39J90%3D”

Rookie Answered on September 10, 2020.
Add Comment

Hi leonardosalatino,

I just remembered this – here’s a Pre-Request Script that sets everything up in Postman. Then you just need to set the Authorization header to {{auth}}.

// SET THESE VALUES
const company_id = '';
const consumer_key = '';
const consumer_secret = '';
 
pm.collectionVariables.set("company_id", company_id);
pm.collectionVariables.set("consumer_key", consumer_key);
pm.collectionVariables.set("consumer_secret", consumer_secret);
pm.collectionVariables.set("state", state);
const url = `https://${company_id.toLowerCase()}.restlets.api.netsuite.com/rest/requesttoken`;
const callback = 'http://localhost';
const nonce = Math.random().toString().substring(2);
const d = new Date();
const timestamp = Math.round(d.getTime() / 1000);
 
let params = `oauth_callback=${encodeURIComponent(callback)}&oauth_consumer_key=${consumer_key}&oauth_nonce=${nonce}&oauth_signature_method=HMAC-SHA256&oauth_timestamp=${timestamp}`;
 
let sig_string = `POST&${encodeURIComponent(url)}&${encodeURIComponent(params)}`;
let sha256digest = CryptoJS.HmacSHA256(sig_string, consumer_secret + '&');
let base64sha256 = CryptoJS.enc.Base64.stringify(sha256digest);
 
let auth = `OAuth oauth_consumer_key="${consumer_key}", oauth_nonce="${nonce}", oauth_timestamp="${timestamp}", oauth_signature_method="HMAC-SHA256", oauth_callback="${encodeURIComponent(callback)}", oauth_signature="${encodeURIComponent(base64sha256)}"`;
 
pm.collectionVariables.set("auth", auth);

Thanks,

Chris

Intermediate Answered on September 10, 2020.
Add Comment

Hi,

I tried to put the role but Iw asn’t able because I’m using the lib oauth1.0a, not sure why it is not taking the role. I tried with postman too, adding the role but faced the same error.

I moved forward with the documentation and realized that in the second step you need to show the consent screen, seems that there is no way to avoid it. But I am in a server side, without user interaction. So, this flow I was trying to use is not for my scenario; I will have to use the eternal tokens.

 

Thanks A LOT for the assistance to both of you!

Rookie Answered on September 11, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor