The JSON-RPC interface provides these methods for logging in:
Log In
Method name:
login
Logs into Origin Storage and obtains a token for subsequent calls. Note that by default the token is valid for one hour. If you want to extend your token’s lifetime, use the
updateSession
call. (See Set Your Token’s Expiry for details.)Log In Using Named Parameters
JSON
1{2 "method": "login",3 "id": 0,4 "params": {5 "username": "yourUser",6 "password": "yourPassword",7 "detail": true8 },9 "jsonrpc": "2.0"10}
Log In Using Positional Parameters
Positional parameters must be applied in the same order shown in the named parameters sample. Example:
JSON
1{2 "method": "login",3 "id": 0,4 "params": [5 "yourUser",6 "yourPassword",7 true8 ],9 "jsonrpc": "2.0"10}
Parameter Descriptions
Parameter Name | Type | Description |
---|---|---|
username | str | User name |
password | str | User password |
detail | bool | Optional Indicates whether to include additional account information in method output. See Response Data for details. Defaults to False . |
Return Codes
- On success the method returns an array with a token and user data.
- If either user or password or both are incorrect, the method returns
[null, null]
.
Other return values:
-32603
: protocol error. You omitted either user or password or both.-40
: You passed an empty string for username.-41
: You passed an empty string for password.
For a list of error codes not specific to login, see Global Error Codes.
Response Data
On success returns an array with a token and user details. The token is the first member of the array. On failure returns
[null, null]
.When the detail parameter is set to False, the method returns the following data:
- gid: (int) caller’s group ID
- token: (str) token for use in subsequent calls
- uid: (int) caller’s user ID
Example:
JSON
1[2 "920cfb89-fc44-4049-a2ea-8f05717eed16",3 {4 "uid": 12020,5 "gid": 1006 }7]
When the detail parameter is set to True, the method returns the following additional data:
- path: (str) user path within namesapce
Example:
JSON
1[2 "44ab329a-316c-40ee-8dce-4be91ca832e2",3 {4 "path": /{your Account name},5 "uid": 12020,6 "gid": 1007 }8]
On failure returns values that represent the nature of the failure as described in Return Codes.
Log in, passing an invalid user:
JSON
1>>> api.login('invalidUser', 'password', True)2[None, None]
Log in, passing an empty string for user:
JSON
1>>> api.login('', 'password', True)2-40
Python Sample Requests
Log in and obtain the token and user information without user details:
Python
1>>> token, user = api.login('user', 'password')2>>> print (token)3u'38c5a5d6-8d0f-47d2-a8f8-ced037a9922e'4>>> user5{u'gid': 100, u'uid': 12020}
Log in and obtain the token and user information with user details:
1>>> token, user = api.login('user', 'password', True)2>>> print (token)3u'38c5a5d6-8d0f-47d2-a8f8-ced037a9922e'4>>> user5{u'path': u'/{your Account name}', u'gid': 100, u'uid': 12020}
Log in and check for errors:
Python
1import jsonrpclib23class LoginError(RuntimeError):4 def __init__(self, arg):5 self.args = arg678yourUser = 'yourUser'9yourPassword = 'yourPassword'10url = 'http://{Account name}.upload.llnw.net/jsonrpc'1112try:13 api = jsonrpclib.Server( url )1415 res = api.login(yourUser, yourPassword, True)1617 if res == -40 or res == -41 or res == -32603:18 msg ='Error logging in.' + '\n Return code: ' + str( res )19 msg += '\n See API documentation for details.'20 raise LoginError( msg )2122 if res == [None, None]:23 raise LoginError('Invalid login credentials: ' + yourUser + ' / ' + yourPassword)2425 token = res[0]26 print token2728 #...2930except LoginError,e:31 print ''.join( e.args )
Log in to a Sub-directory
Method name:
authenticate
Limits operations to a specific sub-directory in a user namespace. The method is a convenience as the directory is treated as a root so you don’t have to include the part of the path above the directory when making calls such as
listDir
. Provides better error codes and allows the caller to optionally set a token expiry and to set the sub-directory per token.This functionality is also available in the HTTP interface by using the
X-Agile-Subdir
header in the /account/login
call. For more information, see Logging in Using the HTTP Interface.Log In Using Named Parameters
JSON
1{2 "method": "authenticate",3 "id": 1,4 "params": {5 "username": "yourUser",6 "password": "yourPassword",7 "expiry": 2800,8 "subdir": "/"9 },10 "jsonrpc": "2.0"11}
Log In Using Positional Parameters
JSON
1{2 "method": "authenticate",3 "id": 0,4 "params": [5 "yourUser",6 "yourPassword",7 2800,8 "/"9 ],10 "jsonrpc": "2.0"11}
Parameter Descriptions
Parameter Name | Type | Description |
---|---|---|
username | str | User name |
password | str | User password |
expiry | int | Optional Amount of time in seconds after which the caller must re-authenticate. Expiry values greater than 24 hours (86400 seconds) are not valid. Defaults to 3600 seconds (one hour). |
subdir | str | Optional The sub-directory to which caller operations will be restricted. Defaults to ’/’ (root). |
Return Codes
- 0: success
- -34: invalid expiry time
- -40: you passed an empty string for username
- -41: you passed an empty string for password
- -47: invalid sub-directory
- -10001: invalid username or password. Or both username and password were not passed
For a list of error codes not specific to
authenticate
, see Global Error Codes.Response Data
On success returns an object with the following data:
- code: (int) always set to 0 (success)
- gid: (int) caller’s group ID
- path: (str) sub-directory to which caller operations will be limited. Includes the caller’s namespace.
- token: (str) token for use in subsequent calls. If you had previously obtained a token with the login method, you can no longer use if after making the call to authenticate.
- uid: (int) caller’s user ID
Example:
1{2 "uid": 12020,3 "path": "/{your Account name}/horticulture/flowers/perrenials",4 "gid": 100,5 "code": 0,6 "token": "e4590b08-7e7d-444a-9bac-41503c00994c"7}
On failure returns an object with values set as follows:
- code: (int) set to one of the non-zero values listed in Return Codes.
- gid: (int) 0
- path: (str) sub-directory passed by the user
- token: null
- uid: (int) 0
Example:
1{2 "uid": 0,3 "path": "/{your Account name}/horticulture/flowers/perrenials",4 "gid": 0,5 "code": -34,6 "token": null7}
Python Sample Request
Python
1>>> api.authenticate('user', 'password', 7200, '/horticulture/flowers/perrenials')2{u'path': u'/{your Account name}/horticulture/flowers/perrenials', u'token': u'42e9aead-92da-4ae4-bd3e-7e967932bh73', u'code': 0, u'uid': 12020, u'gid': 100}