By: Hannah McKee user 05 Dec 2016 at 3:37 a.m. CST

2 Responses
Hannah McKee gravatar
From the Gluu Documentation: > Client Name: This contains the recognizable and unique display name of the client. However, creating a Client both manually, and using the Dynamic Client Registration method, multiple clients with the same name can be created. I have tried to create a custom Client Registration script. However, the problem seems to be that after creating a Client, the getAllClients method in the Client Service is not returning the newly created Client. Custom Client Registration: ``` from org.xdi.model.custom.script.type.client import ClientRegistrationType from org.xdi.util import StringHelper, ArrayHelper from org.xdi.oxauth.service import ScopeService, ClientService from java.util import Arrays, ArrayList import sys import java class ClientRegistration(ClientRegistrationType): def __init__(self, currentTimeMillis): self.currentTimeMillis = currentTimeMillis def init(self, configurationAttributes): self.log("Initialization") self.scopeService = ScopeService.instance() clientService = ClientService.instance() self.existingClients = clientService.getAllClients(["inum", "displayName"]) self.log("Initialized successfully") return True def destroy(self, configurationAttributes): self.log("Destroy") self.log("Destroyed successfully") return True # Update client entry before persisting it # registerRequest is org.xdi.oxauth.client.RegisterRequest # client is org.xdi.oxauth.model.registration.Client # configurationAttributes is java.util.Map<String, SimpleCustomProperty> def updateClient(self, registerRequest, client, configurationAttributes): self.log("Updating Client") if (self.doesDuplicateClientExist(client)): return False self.log("Creating Client " + client.getClientName()) return True def logout(self, configurationAttributes, requestParameters): return True def getApiVersion(self): return 1 def doesDuplicateClientExist(self, client): requestedClientName = client.getClientName() requestedClientId = client.getClientId() self.log("Requested Client Name: " + requestedClientName) self.log("Requested Client Id: " + requestedClientId) for existingClient in self.existingClients: existingClientName = existingClient.getClientName() existingClientId = existingClient.getClientId() #self.log("Existing Client: " + existingClientId + " / " + existingClientName) if (existingClientName == requestedClientName and not (existingClientId == requestedClientId)): self.log("Client already exists with the name '" + requestedClientName + "'") return True return False def log(self, message): print "Unique Client Name Custom Client Registration. " + message def logException(self, message = "Unexpected Exception."): print "Unique Client Name Custom Client Registration. " + message + " Exception: " + sys.exc_info()[1] ```

By Michael Schwartz Account Admin 05 Dec 2016 at 12:34 p.m. CST

Michael Schwartz gravatar
Updating the docs. The name does not have to be unique. That's just a suggestion. [ea5c86](https://github.com/GluuFederation/docs/commit/db23c6855682c5d51964af53794bc63417ea5c86)

By Hannah McKee user 06 Dec 2016 at 2:58 a.m. CST

Hannah McKee gravatar
Thanks, but there were two parts to my question - we want the name to be unique. However, Client service is not returning newly created clients in getAllClients method, similarly it does return recently deleted Clients. What am I doing wrong here?