You can use graph api to list the users and add filter parameter to get the users who are assigned with a particular license. This use case is documented in the following URL.
GET https://graph.microsoft.com/v1.0/users?$select=id,mail,assignedLicenses&$filter=assignedLicenses/any(u:u/skuId eq cbdc14ab-d96c-4c30-b9f4-6ada7cdc1d46)