Child pages
  • GetUser
Skip to end of metadata
Go to start of metadata

Description

The GetUser API retrieves all attributes of a specific User. The Account Owner may call this API to get the attributes of any User, whereas a specific User may call this API to get only his own attributes.

With Apstrata, you can build multi-user applications. In order to be able to read or write data to an apstrata account store, you have to be the Account Owner or you have to be registered as a User in the apstrata account. API requests signed with a User password are User requests as opposed to owner requests which are signed with the account secret.

When you register with Apstrata, an account will be created for you. With each account creation, there is a default user Schema named "apsdb_user" that gets created. The purpose of this Schema is to give the owner the possibility of defining custom user profiles. Hence, an owner can add new fields, define permissions, and define validation rules for each field. When saving users, custom user attributes can be set and validated automatically based on the rules defined for each one. The fields already defined in the default user Schema are required and should not be removed. This user schema is not meant to be used for saving non-user documents.

A User entity is persisted as a Document in the apstrata account user directory Store, based on the Schema named "apsdb_user".

A User can belong to zero or more Groups defining his read and write permissions.

A user can be suspended by calling SaveUser and setting the system field "isSuspended" to true. A suspended user still exists in the system but is treated as if he was deleted. Any request made to Apstrata with this user will return an exception saying that the signature is invalid. The user can be reactivated by calling SaveUser and setting the field "isSuspended" back to false. By default, the ACL of this field are set in a way that only the owner of the account can suspend or un-suspend a user but you are free to change those ACLs by updating your user schema.

Note that owners will always have the permission to call the GetUser and SaveUser APIs, but Users can only read or update their own profile Documents. In other words, the permissions defined in the Schema ACLs can only be used to restrict Users from accessing their own profile Document or other Users profile Documents.

For more details about schema definition, please refer to Document Schema Definition.

Specific Request Parameters

(Refer to Common Request Parameters)

Name

Description

Required

Default

Possible Values

login

The username used to authenticate a user’s requests.

Yes

 

 

apsdb.authTokenThis parameter is used to sign the request with a token that was initially obtained by calling VerifyCredentails  API. For more details on signing requests, please refer to the page entitled Authentication .No  
apsdb.includeFieldTypeTo limit response size, the returned JSON responses do not include field type information for each field in a user document. Setting this paramter to true will cause each user document to have an additional attribute in the JSON response, named "_type", which lists the fields included in the user document and their corresponding field types.Nofalsetrue
false 

Specific Response Elements

(Refer to Common Response Elements)

The following specific "result" element is a child of the common root element "response" and a sibling of the common "metadata" element:

{
	"result": {
	    "user": {
			"name": "user full name",
			"login": "user login name",
			"email": "user email address",
			"groups": [array of strings corresponding to the groups in which the user is a member],
			"custom field 1": "value of custom field 1"
			"custom field 2": "value of custom field 2"
			"custom field n": "value of custom field n"
	    }
	}
}

 

Specific Logical Errors

(Refer to Common Logical Error Codes)

Error

Message

Status Code

PARAMETER_REQUIRED

 

400

INVALID_USER

Identifier [ login ] does not exist.

400

Examples

Sample Request

Request URL: http://sandbox.apstrata.com/apsdb/rest/[authenticationkey]/GetUser?apsws.time=[timestamp]&apsws.authSig=[signature] 


GET parameters:

login=John 


Sample XML Response

Success XML:

<response xmlns="http://www.apstrata.com/services/schemas/apstrata_database_response.xsd">
    <metadata>
        <requestId>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</requestId>
        <status>success</status>       
		<statusCode>200</statusCode>
    </metadata>
    <result>
        <user name="John">
            <attributes>
                <attribute name="Age">
                    <values>
                        <value>32</value>
                    </values>
                </attribute>
                <attribute name="Nationality">
                    <values>
                        <value>/value>
                    </values>
                </attribute> 
            </attributes>
        </user>
    </result>
</response> 



Failure XML:

<response xmlns="http://www.apstrata.com/services/schemas/apstrata_database_response.xsd">
    <metadata>
        <requestId>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</requestId>
        <status>failure</status>
        <errorCode>[errorCode]</errorCode>
        <errorDetail>[failMsg]</errorDetail>
    </metadata>
</response> 



Sample JSON Response

{"response": {
  "metadata": {
    "requestId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "status": "success"
	"statusCode": "200"
 } 
  "result":{ 
	  "user": {
	    "name": "John",
		"Age": "32.0",
		"Nationality": "American"
	   } 
  }
}} 

 

 

  • No labels