In the current website, social login is implemented using the mapping in struts and it will call the custom controller command "XYZThirdPartyLoginCmdImpl" which will authenticate the details passed and it will call the out of the box "LogonCmd" for login.
For creating a REST service for the above functinality, created a custom REST handler " XYZThirdPartyLoginHandler" and from there called the existing command "XYZThirdPartyLoginCmdImpl" using the method executeControllerCommandWithContext. Once the response is generated, WCToken and WCTrustedToken is generated by the below code.
ActivityToken token = getActivityToken();String identitySignature = token.getSignature();String identityId = token.getActivityGUID().getGUID().toString();Map<String, Object> identityTokenInfo = new HashMap();identityTokenInfo.put(MemberFacadeConstants.EC_USERID, new String[] { userId.toString() } );identityTokenInfo.put(MemberFacadeConstants.ACTIVITY_TOKEN_ID, new String[] { identityId } );identityTokenInfo.put(MemberFacadeConstants.ACTIVITY_TOKEN_SIGNATURE, new String[] { identitySignature } );Map<String, String> commerceTokens = CommerceTokenHelper.generateCommerceTokens(identityTokenInfo);String wcToken = commerceTokens.get(CommerceTokenHelper.WC_TOKEN);String wcTrustedToken = commerceTokens.get(CommerceTokenHelper.WC_TRUSTED_TOKEN);The tokens generated using this is not valid. If we try to invoke any other rest service using this token it shows invalid user session error. "XYZThirdPartyLoginCmdImpl" authentication is success as the userId returned is correct. After executing this the user context is not getting created in CTXMGMT table.Please guide on how to generate the valid tokens in REST flow in this use case.