RE: Invalid login attempt on Three Step TBA Authorization Flow

Hello! I am working on setting up the Three-Step TBA Authorization Flow. I am stuck on step one, when I send the POST request, I get:
{“error” : {“code” : “USER_ERROR”, “message” : “Invalid login attempt.”}}

And in the login audit trail the error detail is: “invalidSignature”

Any idea of ​​the possible cause.

Thanks in advance.
JuanArana Rookie Asked on June 30, 2023 in Other.
Add Comment
2 Answers

Hi,

It’s probably not a bad idea to get this working in Postman before first and I have this sample for generating the Authorization header:

 

// SET THESE VALUES
const company_id = 'TSTDRV2257533';
const consumer_key = '0baf0c22d7ddf1f15e4ae6b7ba7284c0b8151a321cebfc45b5d66fb9b52d208b';
const consumer_secret = '67d527e35ee157c70c4e58b3a1c06fad0bfc4a2287fa48bfb20b6948b9eeeeab';
const state = 'https://my_alternative_redirect_url';
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);

 

You then use this here:

RE: Invalid login attempt on Three Step TBA Authorization Flow

Thanks,

Chris

Advanced Answered on July 4, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.