How to get a new UAA guid by REST


Juan Antonio Breña Moral <bren at juanantonio.info...>
 

Hi,

I would like to create users using REST API:
http://apidocs.cloudfoundry.org/222/users/creating_a_user.html

But I don't know how to get a UAA guid of the user to create:

guid-896216bb-a73f-48c1-9824-9c796ad36b7c

How to get it?

Many thanks in advance.

Juan Antonio


Chris De Oliveira
 

Hi,

You can hit the /Users endpoint to create an user in the UAA. You can find more details here https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#create-a-user-post-users

Chris Dutra

On Oct 26, 2015, at 7:38 AM, Juan Antonio Breña Moral <bren(a)juanantonio.info> wrote:

Hi,

I would like to create users using REST API:
http://apidocs.cloudfoundry.org/222/users/creating_a_user.html

But I don't know how to get a UAA guid of the user to create:

guid-896216bb-a73f-48c1-9824-9c796ad36b7c

How to get it?

Many thanks in advance.

Juan Antonio


Aleksey Zalesov
 

Hi,

you need to query UAA API instead of CC API to learn user id.

GET /Users?attributes=id&filter=userName eq 'admin'

UAA endpoint:

$ cat ~/.cf/config.json | jq .UaaEndpoint

To create user you still need to use CC API, as user data goes to both CC and UAA databases. CC then creates UAA user automatically.


Juan Antonio Breña Moral <bren at juanantonio.info...>
 

Hi Aleksey,

do you know where is the documentation for UAA REST API?
For CC API is this address:
http://apidocs.cloudfoundry.org/222/

Juan Antonio


Juan Antonio Breña Moral <bren at juanantonio.info...>
 

Hi I could retrieve the uses but using your clue, I receive the following error:

Error: the string "{\"message\":\"Content type 'application/octet-stream' n
ot supported\",\"error\":\"scim\"}" was thrown, throw an Error :)

I think that my code is OK using the info from Github, but I suppose that I need some additional stuff:

https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#create-a-user-post-users

Users.prototype.add = function (token_type, access_token) {
"use strict";

var url = this.UAA_API_URL + "/Users";

console.log(url);
var options = {
method: 'POST',
url: url,
headers: {
Accept: 'application/json',
Authorization: token_type + ' ' + access_token
}
};

return this.REST.request(options, "200", false);
};

Do you have if I need some additional parameter?

I add the user in UAA to retrieve the guid-uaa and after use this call:
http://apidocs.cloudfoundry.org/222/users/creating_a_user.html

Juan Antonio


Aleksey Zalesov
 

You should use GET request instead of POST. See this topic:

https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#query-for-information-get-users

Alex Zalesov


Juan Antonio Breña Moral <bren at juanantonio.info...>
 

Hi,

many thanks, Aleksey.

Now, I can create and get users from uaa.
https://github.com/cloudfoundry/uaa/issues/249

Now I am going to use guid-uaa to a create an users in CC API.


Juan Antonio Breña Moral <bren at juanantonio.info...>