login(object, success, error)¶
- Call:
appc.gapi.prototype.login(params, success, error)
- Parameters: params, success, error
params: an object:
{
user: "<email format username>",
pwd: "<password>"
}
success: a callback accepting an object:
{
result: <result code>,
token: <authentication token>
gwid: <array of registered gateway ids>
}
error: a callback accepting an object:
{
result: <result code>
}
Description:
Authenticate an account, and create a new authentication token for use in subsequent GAPI calls. A new token is generated each time login is called; any existing token is invalidated. A token may also be invalidated for other reasons, such as a timeout.
The success callback returns an object containing the result, a token, and a list of gateways that are managed by the user's cloud account.
Subsequent calls to config and open may be used to set and open a transport to any of these gateways (default:
gwid[0]
).
Example:
var credentials = {
'user': 'joe@smith.com',
'pwd': 'frobitz$1'
};
gapi.login(credentials,
function(robj) {
var result = robj['result'];
var token = robj['token'];
var gwid = robj['gwid'];
console.log('login: ' + robj.result);
},
function(robj) {
console.log('login: ERROR: ' + robj.result);
});
logout(object, success, error)¶
- Call:
appc.gapi.prototype.logout(params, success, error)
- Parameters: params, success, error
params: an empty object:
{ }
success: a callback accepting an object:
{
result: <result code>
}
error: a callback accepting an object:
{
result: <result code>
}
Description:
Logout from the cloud account. Invalidates authentication token.
Example:
gapi.logout({},
function(robj) {
console.log('logout: ' + robj.result);
}, function(robj) {
console.log('logout: ERROR: ' + robj.result);
});
auth(object, success, error)¶
- Call:
appc.gapi.prototype.auth(params, success, error)
- Parameters: params, success, error
params: an object:
{
user: <email format username>,
pwd: <password>
}
success: a callback accepting an object:
{
result: <result code>,
token: <authentication token>
}
error: a callback accepting an object:
{
result: <result code>
}
Description:
Authenticate and get existing authentication token. Does not create a new token or invalidate the existing token. May be used if multiples instances of
appc.gapi
are needed and a client does not wish to cache a token.
Example:
var object = {
'user': 'joe@smith.com',
'pwd': 'frobitz$1'
};
gapi.auth(object,
function(robj) {
var token = robj['token'];
},
function(robj) {
});