aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/oauth.c17
-rw-r--r--lib/oauth.h35
2 files changed, 36 insertions, 16 deletions
diff --git a/lib/oauth.c b/lib/oauth.c
index 6731fe7e..7897b760 100644
--- a/lib/oauth.c
+++ b/lib/oauth.c
@@ -30,6 +30,7 @@
#include "misc.h"
#include "sha1.h"
#include "url.h"
+#include "oauth.h"
#define CONSUMER_KEY "xsDNKJuNZYkZyMcu914uEA"
#define CONSUMER_SECRET "FCxqcr0pXKzsF9ajmP57S3VQ8V6Drk4o2QYtqMcOszo"
@@ -37,22 +38,6 @@
#define HMAC_BLOCK_SIZE 64
-struct oauth_info;
-typedef void (*oauth_cb)( struct oauth_info * );
-
-struct oauth_info
-{
- oauth_cb func;
- void *data;
-
- struct http_request *http;
-
- char *auth_params;
- char *token;
-
- char *access_token;
-};
-
static char *oauth_sign( const char *method, const char *url,
const char *params, const char *token_secret )
{
diff --git a/lib/oauth.h b/lib/oauth.h
index 98e58c64..91696d83 100644
--- a/lib/oauth.h
+++ b/lib/oauth.h
@@ -21,4 +21,39 @@
* *
\***************************************************************************/
+/* http://oauth.net/core/1.0a/ */
+
+struct oauth_info;
+typedef void (*oauth_cb)( struct oauth_info * );
+
+struct oauth_info
+{
+ oauth_cb func;
+ void *data;
+
+ struct http_request *http;
+
+ char *auth_params;
+ char *token;
+
+ char *access_token;
+};
+
+/* 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. */
+void *oauth_request_token( const char *url, 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 );
+
+/* 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 );