Merge branch 'master' of https://github.com/wso2/carbon-device-mgt-plugins
After Width: | Height: | Size: 170 KiB |
Before Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 507 KiB |
0
components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/images/install_agent.png → components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/images/install_agent1.png
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 304 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 298 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 314 KiB |
@ -0,0 +1,53 @@
|
||||
import json
|
||||
import urllib
|
||||
import iotUtils
|
||||
import requests
|
||||
|
||||
|
||||
applicationKey = None
|
||||
refreshToken = None
|
||||
filename = "deviceConfig.properties"
|
||||
|
||||
|
||||
class RefreshToken():
|
||||
|
||||
def post(self, url, payload, appKey):
|
||||
headers = { 'Authorization' : 'Basic ' + appKey, 'Content-Type' : 'application/x-www-form-urlencoded' }
|
||||
baseUrl = iotUtils.HTTP_EP + url
|
||||
response = requests.post(baseUrl, params=payload, headers=headers);
|
||||
return response
|
||||
|
||||
def read_server_conf(self):
|
||||
with open(filename, 'r') as outfile:
|
||||
conf_file = outfile.readlines()
|
||||
|
||||
return conf_file
|
||||
|
||||
def updateFile(self, response):
|
||||
newRefreshToken = response['refresh_token']
|
||||
newAccessToken = response['access_token']
|
||||
|
||||
with open(filename, 'r+') as f:
|
||||
lines = f.readlines()
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
for line in lines:
|
||||
if line.__contains__("auth-token="):
|
||||
line = "auth-token=" + newAccessToken + "\n"
|
||||
if line.__contains__("refresh-token="):
|
||||
line = "refresh-token=" + newRefreshToken + "\n"
|
||||
f.write(line)
|
||||
|
||||
|
||||
def updateTokens(self,):
|
||||
global applicationKey
|
||||
global refreshToken
|
||||
refreshToken = iotUtils.REFRESH_TOKEN
|
||||
applicationKey = iotUtils.APPLICATION_KEY
|
||||
|
||||
params = urllib.urlencode({"grant_type": "refresh_token", "refresh_token": refreshToken,
|
||||
"scope": "Enroll device"})
|
||||
data = self.post("/token", params, applicationKey)
|
||||
response = json.loads(data)
|
||||
self.updateFile(response)
|
||||
return response
|