ACS Node SDK
The SDK of ACS for NodeJS
Getting started
git clone git+https://github.com/appcelerator/acs-node-sdk.gitcd acs-node-sdknpm install
Basic Example
You can get an overview of ACS Node SDK example from examples/basic.js
cd acs-node-sdk/examplesexport ACS_APPKEY=YOUR_ACS_TEST_APPKEYnode basic.js
ACS Node SDK Example on Node.ACS
There is another example for ACS Node SDK to show how to run on Node.ACS as a service.
Make sure you have installed Node.ACS command line tool first:
sudo npm -g install acs
Then you can try:
cd acs-node-sdk/examples/over_nodeacs# Update config.json to fill in your ACS app key vi config.jsonacs run
Open another session and try:
curl -b cookie.txt -c cookie.txt -X POST -F "login=YOUR_USERNAME" -F "password=YOUR_PASSWORD" http://localhost:8080/logincurl -b cookie.txt -c cookie.txt -X GET http://localhost:8080/showMe
ACS Node SDK Basic Usage
Use ACS Node SDK directly
var ACSNode = ;var acsApp = 'Your_ACS_APPKEY'; acsApp;
Use ACS Node SDK inner express or http/https NodeJS module
// HTTP call 1 with cookie:var acsApp = 'Your_ACS_APPKEY'; acsApp; // HTTP call 2 with cookie, after HTTP call 1:var ACSNode = ;var acsApp = 'Your_ACS_APPKEY'; acsApp;
General RestAPI call
var acsApp = 'Your_ACS_APPKEY'; acsApp;
Session Management
By default, acs-node-sdk will manage sessions for you automatically when you
log in and out. You can create a new ACSNode
instance for each authenticated
session. You can also reuse an existing instance by calling usersLogin()
again,
however this simply overwrites the existing session cookie and will not log out
the previous session.
However, if you'd prefer to manually manage the session cookie, then you can set
the autoSessionManagement
option to false
when the ACSNode
instance is
created.
var acsApp = 'Your_ACS_APPKEY' autoSessionManagement: false;
This means once you log in, you must track the session cookie yourself:
acsApp;
Running Unit Tests
To run the unit tests, simply run:
export ACS_APPKEY=ONE_OF_YOUR_ACS_TEST_APPKEY
npm test
License
This project is open source and provided under the Apache Public License
(version 2). Please make sure you see the LICENSE
file included in this
distribution for more details on the license. Also, please take notice of the
privacy notice at the end of the file.