I am trying to access a TPK for download using HttpURLConnection. The reason I am doing it this way versus
InputStream is = item.fetchData();
is because i want to be able to resume download by setting a Range in Bytes to resume download when a network connection is available again.
Issue is this. I can download a TPK right after logging into the application (before token expires) with the following code...
requestUrl = portal.getUrl() + "/sharing/rest/content/items/" + itemID + "/data?token=" + mValidLoginCredentials.getToken();2. Trying to generate token. Probably bad syntax here...
URL url2 = new URL(requestUrl);
HttpURLConnection urlConnection = (HttpURLConnection) url2.openConnection();urlConnection.setRequestProperty("Range", "bytes=" + (baseMapFile.length()) + "-");
inputStream = new BufferedInputStream(urlConnection.getInputStream(), 16384);
I am wondering how I can regenerate a token from credentials so that I can provide the new token into the requestURL variable.
I have tried a couple of things that do not work...
1. Trying to setUserToken then use it does not work
portal.getCredentials().setUserToken(mValidLoginCredentials.getToken(), portal.getUrl());requestUrl = portal.getUrl() + "/sharing/rest/content/items/" + itemID + "/data?token=" + portal.getCredentials().getToken();requestUrl = portal.getUrl() + "/sharing/rest/content/items/" + itemID + "/data?token=tokens/generateToken?username=mMouse&password=****;
I am pretty sure it is some sort of syntax issue here. Any advice greatly appreciated. Am using Runtime SDK Android 10.2.9.