Minimal HTML:
```html
- <!DOCTYPE html>
- <html>
- <head>
- <script src="./path/to/require.js"></script>
- <script src="./path/to/your/app.js"></script>
- </head>
- <body></body>
- </html>
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src="./path/to/require.js"></script>
+ <script src="./path/to/your/app.js"></script>
+ </head>
+ <body></body>
+</html>
```
Your `app.js`:
```js
- require(['./path/to/remoteStorage'], function(remoteStorage) {
- remoteStorage.getStorageInfo('user@example.com', function(err, storageInfo) {
- var token = remoteStorage.receiveToken();
- if(token) {
- //we can access the 'contacts' category on the remoteStorage of user@example.com:
- var client = remoteStorage.createClient(storageInfo, 'contacts', bearerToken);
- client.put('foo', 'bar', function(err) {
- client.get('foo', function(err, data) {
- client.delete('foo', function(err) {
- });
- });
+require(['./path/to/remoteStorage'], function(remoteStorage) {
+ remoteStorage.getStorageInfo('user@example.com', function(err, storageInfo) {
+ var token = remoteStorage.receiveToken();
+ if(token) {
+ //we can access the 'contacts' category on the remoteStorage of user@example.com:
+ var client = remoteStorage.createClient(storageInfo, 'contacts', bearerToken);
+ client.put('foo', 'bar', function(err) {
+ client.get('foo', function(err, data) {
+ client.delete('foo', function(err) {
});
- } else {
- //get an access token for 'sandwiches' by dancing OAuth with the remoteStorage of user@example.com:
- window.location = remoteStorage.createOAuthAddress(storageInfo, ['contacts'], window.location.href);
- }
+ });
});
- });
+ } else {
+ //get an access token for 'sandwiches' by dancing OAuth with the remoteStorage of user@example.com:
+ window.location = remoteStorage.createOAuthAddress(storageInfo, ['contacts'], window.location.href);
+ }
+ });
+});
```
#Function reference