Hi,
We have a error when try to get the token in
https://{CA-SERVER}/capi/rest/token
When i tried to get te token i recivied the error:
Error Code=TokenService.003
Error Operation=token resource
Error Class Name=conferencing.avaya.com.Error
Error Message=Could not validate the token request.
I atached the log detail file and the capi rest description.
The Steps:
1) Client makes a request for a temporary “nonce” including “subject” as a request parameter.
nonce= MTQzNTM2MDQwOTQ3MDczYzM0MzhlMjczMzkyM2EwODc0YWIzZGI4ZjcxYmU4
2) Client generates a special HMAC value (HmacSHA1 is used now). API key is used as a signing key and (nonce+API ID) is used as a signing value.
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(new SecretKeySpec(this.API_KEY.getBytes(), "HmacSHA1"));
String signature = new String(mac.doFinal((nonce.getNonce()+this.API_ID).getBytes()));
3) Client requests for a token including API ID, HMAC and subject the server tries to validate the input.
Object resp = parseResponse( SendRequestPost(list, "/capi/rest/token") );
if(resp instanceof conferencing.avaya.com.Error){
throw new AAC8Exception( (conferencing.avaya.com.Error)resp);
} else
return (conferencing.avaya.com.OAuth2Token) resp;
public conferencing.avaya.com.OAuth2Token GetToken(conferencing.avaya.com.Nonce nonce)
throws IOException, JAXBException, URISyntaxException, AAC8Exception, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException{
List<NameValuePair> list = new ArrayList<>();
list.add( new Parametro("subject",nonce.getUserName()) );
list.add( new Parametro("apiId",this.API_ID) );
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(new SecretKeySpec(this.API_KEY.getBytes(), "HmacSHA1"));
String signature = new String(mac.doFinal((nonce.getNonce()+this.API_ID).getBytes()));
list.add( new Parametro("hmac",signature) );
Object resp = parseResponse( SendRequestPost(list, "/capi/rest/token") );
if(resp instanceof conferencing.avaya.com.Error){
throw new AAC8Exception( (conferencing.avaya.com.Error)resp);
} else
return (conferencing.avaya.com.OAuth2Token) resp;
}
protected String SendRequestPost(List<NameValuePair> parameters, String path)
throws IOException, URISyntaxException, JAXBException {
CloseableHttpResponse response = null;
URIBuilder uri = null;
HttpPost post = null;
String res = null;
try {
uri = new URIBuilder();
uri.setScheme(“https");
uri.setHost("ca-demo.tvg.com.mx");
uri.setPath("/capi/rest/token");
post = new HttpPost(uri.build());
post.setEntity( new UrlEncodedFormEntity(parameters) );
post.addHeader("Accept", "application/xml");
response = this.getHttpClient().execute(post);
res = EntityUtils.toString(response.getEntity());
if (DEBUG) {
printResponseInfo(response);
}
return res;
} finally {
if (response != null) {
response.close();
}
}
}
Regards,