ClientRequest request = new ClientRequest(ConsumerScopesRegistrationURL);
String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
request.header("Authorization", "Basic " + base64Credentials);
request.formParameter(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
request.formParameter("xoauth_scope", scope);
request.formParameter("xoauth_permission", "sendMessages");
ClientResponse<?> response = null;
try {
response = request.post();
if (HttpResponseCodes.SC_OK != response.getStatus()) {
throw new RuntimeException("Scopes can not be registered");