Wednesday, January 21, 2015 at 5:28 PM

How it flows

Here's the basic flow for connecting with the Storage server.

  1. When your app starts up, call twGetOauthParams. You'll see how this is connected to the flow in step 4 below. That's the nature of OAuth, you have to understand how it flows before getting started.

  2. Call twIsTwitterConnected to see if the user is currently logged into Twitter in your app. If it isn't put up a message saying they have to be logged into Twitter to use your app and provide a way for them to connect (see step 4).

  3. If the user is logged into Twitter, get your prefs, open a document, do whatever you want with the storage. You can now make requests that get both public and private info for the user.

  4. Suppose you have a button that says Log In To Twitter. When clicked, that button would call twConnectToTwitter, which calls the server which then begins the dance with Twitter. It sends the address of your app to the server, so it can relaunch it after the user authorizes. When that happens your app will pick up the OAuth credentials in step 1 above. Those credentials are kept in localStorage on the user's machine and are parameters to all the API calls.


Call this API routine to upload a file to the server.

twUploadFile ("hello.txt", "hello world", "text/plain", false)

The last param, false, says that the file is not private.

There's a fifth, optional param, that's a callback that gets a bunch of info about the file, including its URL, if it's public.

Demo app

BTW, I'm just including this here to give you an idea of how this works. There's a simple demo app that illustrates it with working JS code.

Last built: Wed, Mar 25, 2015 at 4:38 PM

By Dave Winer, Wednesday, January 21, 2015 at 5:28 PM. When in doubt, blog.