How to add user group info as part of access token?

Tried below code for fetching group information , but I didn’t get group info as part of access token

// rule script
context.idToken[namespace + ‘/groups’] = user.groups;