diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-05-02 22:20:09 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-05-02 22:20:09 +0100 |
commit | 3b878a1c3d0888b0669c30433efab914061fa61d (patch) | |
tree | 629406231f5b1be0236e89b928611f15e0ecba91 /lib/oauth.h | |
parent | 839189b091ee82937666bcaa328a7d3ecd1c573b (diff) | |
parent | f4b0911d037c02f8b9190518b5efda4368dcc25b (diff) |
OAuth sanity fix: Twitter-specific stuff should *not* be in lib/oauth.c.
Somewhat intrusive, should've done this right immediately. :-/
Diffstat (limited to 'lib/oauth.h')
-rw-r--r-- | lib/oauth.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/oauth.h b/lib/oauth.h index a61650cc..5dfe0ae5 100644 --- a/lib/oauth.h +++ b/lib/oauth.h @@ -39,36 +39,52 @@ typedef enum struct oauth_info { oauth_stage_t stage; + const struct oauth_service *sp; oauth_cb func; void *data; struct http_request *http; - char *auth_params; + char *auth_url; char *request_token; - char *access_token; + char *token; + char *token_secret; +}; + +struct oauth_service +{ + char *url_request_token; + char *url_access_token; + char *url_authorize; + + char *consumer_key; + char *consumer_secret; }; /* http://oauth.net/core/1.0a/#auth_step1 (section 6.1) Request an initial anonymous token which can be used to construct an authorization URL for the user. This is passed to the callback function in a struct oauth_info. */ -struct oauth_info *oauth_request_token( const char *url, oauth_cb func, void *data ); +struct oauth_info *oauth_request_token( const struct oauth_service *sp, oauth_cb func, void *data ); /* http://oauth.net/core/1.0a/#auth_step3 (section 6.3) The user gets a PIN or so which we now exchange for the final access token. This is passed to the callback function in the same struct oauth_info. */ -void oauth_access_token( const char *url, const char *pin, struct oauth_info *st ); +gboolean oauth_access_token( const char *pin, struct oauth_info *st ); /* http://oauth.net/core/1.0a/#anchor12 (section 7) Generate an OAuth Authorization: HTTP header. access_token should be saved/fetched using the functions above. args can be a string with whatever's going to be in the POST body of the request. GET args will automatically be grabbed from url. */ -char *oauth_http_header( char *access_token, const char *method, const char *url, char *args ); +char *oauth_http_header( struct oauth_info *oi, const char *method, const char *url, char *args ); /* Shouldn't normally be required unless the process is aborted by the user. */ void oauth_info_free( struct oauth_info *info ); + +/* Convert to and back from strings, for easier saving. */ +char *oauth_to_string( struct oauth_info *oi ); +struct oauth_info *oauth_from_string( char *in, const struct oauth_service *sp ); |