Hi,
This is my first post and I hope that you can helpme. I can't create a token ID, Previously I worked with API purecloud and Visual Studio C# and I created a token without problems and easy.
Example C#:
var accessTokenInfo = Configuration.Default.ApiClient.PostToken("CLIENTID_XXXXXXXXXXXX", "SECRET_XXXXXXXXXXXXXXXXXX");
Console.WriteLine("Access token=" + accessTokenInfo.AccessToken);
var token = accessTokenInfo.AccessToken;
Configuration.Default.AccessToken = token;
Actually I working with API purecloud and Java SDK, but I can´t create a token ID. I looked the Purecloud Documentation and Developer Forum but i can´t find the solution. i looked examples base64 encode in https://developer.mypurecloud.com/api/rest/authorization/base-64-encoding.html
and https://developer.mypurecloud.com/api/rest/client-libraries/java/index.html
I'm working with a manual token (in C# created) for execute many API Purecloud in java, I tried many solution but my problem continues. this is my actual
code in JAVA SDK.
Return: "Method Not Allowed"
public void getURL() throws UnsupportedEncodingException
{
String clientid ="XXXXXXXXXXXX-XXXXXXXXXXXXXX-";
String clientSecret = "XXXXXXXXXXXXXXXxxxxxXXXXXXXXX";
Base64 base64 = new Base64();
String encodeData = new String(Base64.encodeBase64((clientid+":"+clientSecret).getBytes("ISO-8859-1")));
System.out.println(encodeData);
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet post = new HttpGet("https://login.mypurecloud.com/oauth/token");
post.setHeader("Authorization", "Basic" +encodeData );
post.setHeader("Content-Type","application/x-www-form-urlencoded");
//post.setHeader("grant_type", "client_credentials");
JSONObject json = new JSONObject();
json.put("", "");
// json.put ...
// Send it as request body in the post request
StringEntity params = null;
try {
params = new StringEntity(json.toString());
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
HttpParams parametrosList;
//parametrosList.setParameter(name, value);
//post.setParams(prametrosList);
try {
CloseableHttpResponse response = httpclient.execute(post);
HttpEntity f = response.getEntity();
String salida = EntityUtils.toString(response.getEntity(), Charset);
System.out.println(salida);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
httpclient.getConnectionManager().shutdown();
}
}
Is there another way?
best regards
Jorge