Wednesday, December 10, 2014 at 11:33 AM

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.

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

Last built: Sun, May 10, 2015 at 8:33 AM

By Dave Winer, Wednesday, December 10, 2014 at 11:33 AM. You should never argue with a crazy man.