- Verify the identity of the user by the native app, i.e., facebook and get a access_token.
- Use the access_token to login.
These are the TODO items. Feel free to contribute.
- Currently only supports facebook, add other identity providers.
- Add support for Admin level access.
-
Download
WindowsAzure.jsand put it in theResources/lib/directory. -
Initialize :
var WindowsAzure = require('lib/WindowsAzure'); var mClient = new WindowsAzure.MobileServiceClient('https://my-azure-app.azure-mobile.net/','my-azure-secret'); -
Login :
mClient.login(WindowsAzure.MobileServiceAuthenticationProvider.Facebook,'facebook_access_token', function(_error,_user){ if(_error){ //handle _error } else{ //_user.getUserId() and _user.getAuthenticationToken() available } } ); -
Look up a table :
// by the primary id // Depricated: this method is depricated since version 1.1.0, use MobileServiceTable.prototype.select instead mClient.getTable('my-table-name').lookUp('unique-primary-key',function(_error,_obj){ if(_error){ //handle _error } else{ //_obj.column_name to access each column of the returned row } }); mClient.getTable('my-table-name').select(function(_error,_obj){ if(_error){ //handle _error } else{ //_obj.column_name to access each column of the returned row } }, 'unique-primary-key : put null for all rows', ['column_name_1','column_name_1'], // put null to return all the columns '(column_1 eq some_value)'); // where string, look: http://msdn.microsoft.com/en-us/library/azure/jj677199.aspx -
Insert to a table :
mClient.getTable('my-table-name').insert({ 'column_1': 'column_1_value', 'column_2': 'column_2_value' },function(_error,_obj){ if(_error){ //handle _error } else{ //_obj.column_name to access each column of the newly inserted row } }); -
Update a row of a table :
mClient.getTable('my-table-name').update('unique-primary-key', { 'column_1': 'updated_1_value', 'column_2': 'updated_2_value' }, function(_error,_obj){ if(_error){ //handle _error } else{ //_obj.column_name to access each column of the updated row } }); -
Delete a row from a table by the primary id :
mClient.getTable('my-table-name').del('unique-primary-key',function(_error,_obj){ if(_error){ //handle _error } else{ //successful } }); -
Calling custom API by HTTP GET:
mClient.invokeGetApi('api_name',{ 'url_param_1' : 'some value', 'url_param_2' : 'other value' }, function(_error,_obj){ if(_error){ //handle _error } else{ //_obj is the GET response. } } ); -
Calling custom API by HTTP POST:
mClient.invokePostApi('api_name',{ 'req_body_1' : 'some value', 'req_body_2' : 'this can be a complex object' }, function(_error,_obj){ if(_error){ //handle _error } else{ //_obj is the POST response. } } ); -
Calling custom API by HTTP PUT:
mClient.invokePutApi('api_name',{ 'req_body_1' : 'some value to be updated', 'req_body_2' : 'this can be a complex object' }, { 'url_param_1' : 'ideally an id to uniquely identify the object to update', 'url_param_2' : 'some other value' } function(_error,_obj){ if(_error){ //handle _error } else{ //_obj is the PUT response. } } ); -
Calling custom API by HTTP PATCH:
mClient.invokePatchApi('api_name',{ 'req_body_1' : 'some value to be updated', 'req_body_2' : 'this can be a complex object' }, { 'url_param_1' : 'ideally an id to uniquely identify the object to update', 'url_param_2' : 'some other value' } function(_error,_obj){ if(_error){ //handle _error } else{ //_obj is the PATCH response. } } ); -
Calling custom API by HTTP DELETE:
mClient.invokeDeleteApi('api_name', { 'url_param_1' : 'ideally an id to uniquely identify the object to delete', 'url_param_2' : 'may be u need 2 values to uniquely identify the object' } function(_error,_obj){ if(_error){ //handle _error } else{ //_obj is the DELETE response. } } );