|
|
|
@ -357,6 +357,7 @@ public class DeviceTypeServiceImpl implements DeviceTypeService {
|
|
|
|
|
if (apiApplicationKey == null) {
|
|
|
|
|
String applicationUsername = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm()
|
|
|
|
|
.getRealmConfiguration().getAdminUserName();
|
|
|
|
|
applicationUsername = applicationUsername + "@" + APIUtil.getAuthenticatedUserTenantDomain();
|
|
|
|
|
APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService();
|
|
|
|
|
String[] tags = {DeviceTypeConstants.DEVICE_TYPE};
|
|
|
|
|
apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
|
|
|
|
@ -365,7 +366,8 @@ public class DeviceTypeServiceImpl implements DeviceTypeService {
|
|
|
|
|
JWTClient jwtClient = APIUtil.getJWTClientManagerService().getJWTClient();
|
|
|
|
|
String scopes = "device_type_" + DeviceTypeConstants.DEVICE_TYPE + " device_" + deviceId;
|
|
|
|
|
AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(apiApplicationKey.getConsumerKey(),
|
|
|
|
|
apiApplicationKey.getConsumerSecret(), owner, scopes);
|
|
|
|
|
apiApplicationKey.getConsumerSecret(), owner + "@" + APIUtil.getAuthenticatedUserTenantDomain(), scopes);
|
|
|
|
|
|
|
|
|
|
//create token
|
|
|
|
|
String accessToken = accessTokenInfo.getAccessToken();
|
|
|
|
|
String refreshToken = accessTokenInfo.getRefreshToken();
|
|
|
|
|