mitsuhiko/flask-oauth — pull request #16 by nvie (2011-11-06 13:08:24+00:00)
Title: Add support to send requests on behalf of multiple OAuth tokens

Currently, Flask-OAuth supported only a single token per OAuth instance. This means that you can, for example, sign up with your Twitter account, and send tweets from that account, but if you sign up with multiple Twitter accounts, you are unable to send tweets from an arbitrary one of them (at least not without residing to evil solutions like keeping global state with the "default" OAuth token to use).

What this patch adds:

* Each of OAuth's request methods (get, post, put, delete, and request) gets an optional `token` argument, which can be passed in to send the request using that token.
* The token will be passed to the `tokengetter_func`. The tokengetter function thus can be prepared to receive a `token` argument. For example:

@twitter.tokengetter
def my_token_getter(token=None):
if token is not None: # During auth, token won't be passed
oauth_secret = get_my_secret_for_token(token)
return (token, oauth_secret)
return None

* For backwards-compatibility, the `token` argument will only be passed to the `tokengetter_func` when it is explicitly passed as a kwarg to one of the request methods.

@mitsuhiko: Please let me know what you think of this patch or this approach. If you'd like to merge this in Flask-OAuth, I'd be happy to write paragraph or two of documentation for this patch, too.