mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Append tenant domain when getting default access token
This commit is contained in:
parent
6250921c6f
commit
51fface401
@ -1463,12 +1463,18 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
@GET
|
@GET
|
||||||
@Path("/{clientId}/{clientSecret}/default-token")
|
@Path("/{clientId}/{clientSecret}/default-token")
|
||||||
@Override
|
@Override
|
||||||
public Response getDefaultToken(@PathParam("clientId") String clientId, @PathParam("clientSecret") String clientSecret) {
|
public Response getDefaultToken(
|
||||||
|
@PathParam("clientId") String clientId,
|
||||||
|
@PathParam("clientSecret") String clientSecret) {
|
||||||
JWTClientManagerService jwtClientManagerService = DeviceMgtAPIUtils.getJWTClientManagerService();
|
JWTClientManagerService jwtClientManagerService = DeviceMgtAPIUtils.getJWTClientManagerService();
|
||||||
try {
|
try {
|
||||||
JWTClient jwtClient = jwtClientManagerService.getJWTClient();
|
JWTClient jwtClient = jwtClientManagerService.getJWTClient();
|
||||||
AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(clientId, clientSecret,
|
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(), "default");
|
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||||
|
if (!"carbon.super".equals(tenantDomain)) {
|
||||||
|
username += "@" + tenantDomain;
|
||||||
|
}
|
||||||
|
AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(clientId, clientSecret, username, "default");
|
||||||
return Response.status(Response.Status.OK).entity(accessTokenInfo).build();
|
return Response.status(Response.Status.OK).entity(accessTokenInfo).build();
|
||||||
} catch (JWTClientException e) {
|
} catch (JWTClientException e) {
|
||||||
String msg = "Error occurred while getting default access token by using given client Id and client secret.";
|
String msg = "Error occurred while getting default access token by using given client Id and client secret.";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user