[YMCS/YDMP Free Trial Program]Yealink would like to offer Free Trial Program of Yealink device management service for our current eligible customers. You can see the details below.
https://www.yealink.com/ydmp-freetrial-2020


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RPS API - Authentication Error
Author Message
jrmende5 Offline
Junior Member
**

Posts: 2
Joined: Nov 2019
Reputation: 0
Post: #1
RPS API - Authentication Error
Good day.

I am working on connecting to the RPS API using the new version (REST server using Access Key and Access Key Secret) from POSTMAN.

But I receive the error: 401 - signature.invalid

I attach the code in postman (Pre-request script):

function getTimestp(){
dt = new Date();
return dt.getTime();
}

function getNonce(){
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + s4() + s4() + s4() + s4() + s4() + s4();
}


xkey = "AccessKey";
xsecret = "SecretKey";
xtimest = getTimestp();
xnonce = getNonce();

xheaders = "X-Ca-Key:"+xkey+"\n"+"X-Ca-Nonce:"+xnonce+"\n"+"X-Ca-Timestamp:"+xtimest;

param = pm.request.body.formdata;
dp = Object.values(param);
lg = dp[0];

stparam = "";

for(i=0;i<lg.length;i++){
aPam = lg[i];

equal = "=";
if(aPam["value"] === ""){
equal = "";
}

if(i+1 == lg.length){
stparam += aPam["key"]+equal+aPam["value"];
}else{
stparam += aPam["key"]+equal+aPam["value"]+"&";
}
}


stringToSign = "POST\n"+xheaders+"\n"+pm.request.url.getPath()+"\n"+stparam;

signatureutf8 = CryptoJS.enc.Utf8.parse(stringToSign);
secretByteArray = CryptoJS.enc.Utf8.parse(xsecret);
signatureBytes = CryptoJS.HmacSHA256(signatureutf8,secretByteArray);
requestSignatureBase64String = CryptoJS.enc.Base64.stringify(signatureBytes);

pm.environment.set("signature",requestSignatureBase64String);
11-22-2019 12:08 AM
Find all posts by this user    like0    dislike0 Quote this message in a reply
jrmende5 Offline
Junior Member
**

Posts: 2
Joined: Nov 2019
Reputation: 0
Post: #2
RE: RPS API - Authentication Error
friendly bump
11-26-2019 08:02 PM
Find all posts by this user    like0    dislike0 Quote this message in a reply
complex1 Offline
3CX Adv. Cert. Engineer
*****

Posts: 992
Joined: Jan 2014
Reputation: 25
Post: #3
RE: RPS API - Authentication Error
Hi,

I can’t really help you on this, but may I suggest to submit a ticket to support?
https://ticket.yealink.com/

Hope this will help.

Best regards,
Frank.

Dutch is my native language, not English. Apologies for my imperfect grammar.
Please do not send unsolicited PM messages. I will not answer them.
11-28-2019 11:24 AM
Find all posts by this user    like0    dislike0 Quote this message in a reply
bmueller Offline
Junior Member
**

Posts: 1
Joined: Jan 2019
Reputation: 0
Post: #4
RE: RPS API - Authentication Error
(11-22-2019 12:08 AM)jrmende5 Wrote:  Good day.

I am working on connecting to the RPS API using the new version (REST server using Access Key and Access Key Secret) from POSTMAN.

But I receive the error: 401 - signature.invalid

I attach the code in postman (Pre-request script):

function getTimestp(){
dt = new Date();
return dt.getTime();
}

function getNonce(){
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + s4() + s4() + s4() + s4() + s4() + s4();
}


xkey = "AccessKey";
xsecret = "SecretKey";
xtimest = getTimestp();
xnonce = getNonce();

xheaders = "X-Ca-Key:"+xkey+"\n"+"X-Ca-Nonce:"+xnonce+"\n"+"X-Ca-Timestamp:"+xtimest;

param = pm.request.body.formdata;
dp = Object.values(param);
lg = dp[0];

stparam = "";

for(i=0;i<lg.length;i++){
aPam = lg[i];

equal = "=";
if(aPam["value"] === ""){
equal = "";
}

if(i+1 == lg.length){
stparam += aPam["key"]+equal+aPam["value"];
}else{
stparam += aPam["key"]+equal+aPam["value"]+"&";
}
}


stringToSign = "POST\n"+xheaders+"\n"+pm.request.url.getPath()+"\n"+stparam;

signatureutf8 = CryptoJS.enc.Utf8.parse(stringToSign);
secretByteArray = CryptoJS.enc.Utf8.parse(xsecret);
signatureBytes = CryptoJS.HmacSHA256(signatureutf8,secretByteArray);
requestSignatureBase64String = CryptoJS.enc.Base64.stringify(signatureBytes);

pm.environment.set("signature",requestSignatureBase64String);

Did you ever get this solved? I am having the same issues...
01-06-2020 02:35 PM
Find all posts by this user    like0    dislike0 Quote this message in a reply
TeleCloud Offline
Junior Member
**

Posts: 1
Joined: May 2019
Reputation: 0
Post: #5
RE: RPS API - Authentication Error
(01-06-2020 02:35 PM)bmueller Wrote:  
(11-22-2019 12:08 AM)jrmende5 Wrote:  Good day.

I am working on connecting to the RPS API using the new version (REST server using Access Key and Access Key Secret) from POSTMAN.

But I receive the error: 401 - signature.invalid

I attach the code in postman (Pre-request script):

function getTimestp(){
dt = new Date();
return dt.getTime();
}

function getNonce(){
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + s4() + s4() + s4() + s4() + s4() + s4();
}


xkey = "AccessKey";
xsecret = "SecretKey";
xtimest = getTimestp();
xnonce = getNonce();

xheaders = "X-Ca-Key:"+xkey+"\n"+"X-Ca-Nonce:"+xnonce+"\n"+"X-Ca-Timestamp:"+xtimest;

param = pm.request.body.formdata;
dp = Object.values(param);
lg = dp[0];

stparam = "";

for(i=0;i<lg.length;i++){
aPam = lg[i];

equal = "=";
if(aPam["value"] === ""){
equal = "";
}

if(i+1 == lg.length){
stparam += aPam["key"]+equal+aPam["value"];
}else{
stparam += aPam["key"]+equal+aPam["value"]+"&";
}
}


stringToSign = "POST\n"+xheaders+"\n"+pm.request.url.getPath()+"\n"+stparam;

signatureutf8 = CryptoJS.enc.Utf8.parse(stringToSign);
secretByteArray = CryptoJS.enc.Utf8.parse(xsecret);
signatureBytes = CryptoJS.HmacSHA256(signatureutf8,secretByteArray);
requestSignatureBase64String = CryptoJS.enc.Base64.stringify(signatureBytes);

pm.environment.set("signature",requestSignatureBase64String);

Did you ever get this solved? I am having the same issues...

Anyone get this working?
can we please have some sample code.
Thanks
03-13-2020 06:01 AM
Find all posts by this user    like0    dislike0 Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Autoprovisionong T4xS v83 error gasper_s 2 2,208 11-05-2018 10:25 AM
Last Post: gasper_s
  T32G Auto provisioning error with encryption Mike89 0 1,783 09-18-2017 12:47 AM
Last Post: Mike89
  Upgrade firmware error from tftp boot server guillosur 1 4,125 05-05-2016 06:18 AM
Last Post: Karl_Yealink
  HTTPS/SSL Error nickcoons 18 37,357 02-28-2016 10:17 AM
Last Post: Novum Networks
  Incorrect File Format error on call send, receive or end call morrism 4 7,536 10-06-2015 07:37 AM
Last Post: morrism
  Auto Provisioning error AndyInNYC 1 6,781 09-10-2014 10:19 AM
Last Post: Wilson_Yealink

Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us   Yealink   Return to Top   Return to Content   Lite (Archive) Mode   RSS Syndication