Index: lib/oauth.c
===================================================================
--- lib/oauth.c	(revision b2bc25c4483f4c2b419d91d479f38c3f07ef4226)
+++ lib/oauth.c	(revision 508c340d1d12d3ca932001d7ee1dea1a4c81bf02)
@@ -175,7 +175,6 @@
 }
 
-GSList *oauth_params_parse( char *in )
-{
-	GSList *ret = NULL;
+static void oauth_params_parse( GSList **params, char *in )
+{
 	char *amp, *eq;
 	
@@ -190,5 +189,5 @@
 			*amp = '\0';
 		
-		oauth_params_add( &ret, in, eq + 1 );
+		oauth_params_add( params, in, eq + 1 );
 		
 		*eq = '=';
@@ -199,6 +198,4 @@
 		in = amp + 1;
 	}
-	
-	return ret;
 }
 
@@ -312,8 +309,8 @@
 	if( req->status_code == 200 )
 	{
-		GSList *params;
+		GSList *params = NULL;
 		
 		st->auth_params = g_strdup( req->reply_body );
-		params = oauth_params_parse( st->auth_params );
+		oauth_params_parse( &params, st->auth_params );
 		st->token = g_strdup( oauth_params_get( &params, "oauth_token" ) );
 		oauth_params_free( &params );
@@ -345,11 +342,11 @@
 }
 
-char *oauth_http_header( char *access_token, const char *method, const char *url )
-{
-	GSList *params, *l;
-	char *token_secret, *sig, *params_s;
+char *oauth_http_header( char *access_token, const char *method, const char *url, char *args )
+{
+	GSList *params = NULL, *l;
+	char *token_secret, *sig, *params_s, *s;
 	GString *ret = NULL;
 	
-	params = oauth_params_parse( access_token );
+	oauth_params_parse( &params, access_token );
 	if( params == NULL )
 		goto err;
@@ -361,4 +358,32 @@
 	oauth_add_default_params( &params );
 	
+	ret = g_string_new( "OAuth " );
+	for( l = params; l; l = l->next )
+	{
+		char *kv = l->data;
+		char *eq = strchr( kv, '=' );
+		char esc[strlen(kv)*3+1];
+		
+		if( eq == NULL )
+			break; /* WTF */
+		
+		strcpy( esc, eq + 1 );
+		http_encode( esc );
+		
+		g_string_append_len( ret, kv, eq - kv + 1 );
+		g_string_append_c( ret, '"' );
+		g_string_append( ret, esc );
+		g_string_append( ret, "\", " );
+	}
+	
+	if( args )
+		oauth_params_parse( &params, args );
+	if( ( s = strchr( url, '?' ) ) )
+	{
+		s = g_strdup( s + 1 );
+		oauth_params_parse( &params, s + 1 );
+		g_free( s );
+	}
+	
 	params_s = oauth_params_string( params );
 	sig = oauth_sign( method, url, params_s, token_secret );
@@ -367,23 +392,4 @@
 	http_encode( sig );
 	
-	ret = g_string_new( "OAuth " );
-	for( l = params; l; l = l->next )
-	{
-		char *kv = l->data;
-		char *eq = strchr( kv, '=' );
-		char esc[strlen(kv)*3+1];
-		
-		if( eq == NULL )
-			break; /* WTF */
-		
-		strcpy( esc, eq + 1 );
-		http_encode( esc );
-		
-		g_string_append_len( ret, kv, eq - kv + 1 );
-		g_string_append_c( ret, '"' );
-		g_string_append( ret, esc );
-		g_string_append( ret, "\", " );
-	}
-	
 	g_string_append_printf( ret, "oauth_signature=\"%s\"", sig );
 	
Index: lib/oauth.h
===================================================================
--- lib/oauth.h	(revision b2bc25c4483f4c2b419d91d479f38c3f07ef4226)
+++ lib/oauth.h	(revision 508c340d1d12d3ca932001d7ee1dea1a4c81bf02)
@@ -21,2 +21,4 @@
 *                                                                           *
 \***************************************************************************/
+
+char *oauth_http_header( char *access_token, const char *method, const char *url, char *args );
Index: protocols/twitter/twitter.c
===================================================================
--- protocols/twitter/twitter.c	(revision b2bc25c4483f4c2b419d91d479f38c3f07ef4226)
+++ protocols/twitter/twitter.c	(revision 508c340d1d12d3ca932001d7ee1dea1a4c81bf02)
@@ -82,5 +82,8 @@
 
 	td->user = acc->user;
-	td->pass = acc->pass;
+	if( strstr( acc->pass, "oauth_token=" ) == NULL )
+		td->pass = g_strdup( acc->pass );
+	else
+		td->oauth = g_strdup( acc->pass );
 	td->home_timeline_id = 0;
 
@@ -119,4 +122,6 @@
 	if( td )
 	{
+		g_free( td->pass );
+		g_free( td->oauth );
 		g_free( td );
 	}
Index: protocols/twitter/twitter.h
===================================================================
--- protocols/twitter/twitter.h	(revision b2bc25c4483f4c2b419d91d479f38c3f07ef4226)
+++ protocols/twitter/twitter.h	(revision 508c340d1d12d3ca932001d7ee1dea1a4c81bf02)
@@ -37,4 +37,5 @@
 	char* user;
 	char* pass;
+	char* oauth;
 	guint64 home_timeline_id;
 	gint main_loop_id;
Index: protocols/twitter/twitter_http.c
===================================================================
--- protocols/twitter/twitter_http.c	(revision b2bc25c4483f4c2b419d91d479f38c3f07ef4226)
+++ protocols/twitter/twitter_http.c	(revision 508c340d1d12d3ca932001d7ee1dea1a4c81bf02)
@@ -35,4 +35,5 @@
 #include "misc.h"
 #include "base64.h"
+#include "oauth.h"
 #include <ctype.h>
 #include <errno.h>
@@ -45,5 +46,5 @@
  * This is actually pretty generic function... Perhaps it should move to the lib/http_client.c
  */
-void *twitter_http(char *url_string, http_input_function func, gpointer data, int is_post, char* user, char* pass, char** arguments, int arguments_len)
+void *twitter_http(char *url_string, http_input_function func, gpointer data, int is_post, char* user, char* pass, char* oauth_token, char** arguments, int arguments_len)
 {
 	url_t *url = g_new0( url_t, 1 );
@@ -110,5 +111,18 @@
 
 	// If a pass and user are given we append them to the request.
-	if (userpass_base64)
+	if (oauth_token)
+	{
+		char *full_header;
+		
+		full_header = oauth_http_header(oauth_token,
+		                                is_post ? "POST" : "GET",
+		                                url_string, url_arguments);
+		
+		tmp = g_strdup_printf("%sAuthorization: %s\r\n", request, full_header);
+		g_free(request);
+		g_free(full_header);
+		request = tmp;
+	}
+	else if (userpass_base64)
 	{
 		tmp = g_strdup_printf("%sAuthorization: Basic %s\r\n", request, userpass_base64);
Index: protocols/twitter/twitter_http.h
===================================================================
--- protocols/twitter/twitter_http.h	(revision b2bc25c4483f4c2b419d91d479f38c3f07ef4226)
+++ protocols/twitter/twitter_http.h	(revision 508c340d1d12d3ca932001d7ee1dea1a4c81bf02)
@@ -29,5 +29,5 @@
 
 void *twitter_http(char *url_string, http_input_function func, gpointer data, int is_post, 
-					char* user, char* pass, char** arguments, int arguments_len);
+                   char* user, char* pass, char *oauth_token, char** arguments, int arguments_len);
 
 #endif //_TWITTER_HTTP_H
Index: protocols/twitter/twitter_lib.c
===================================================================
--- protocols/twitter/twitter_lib.c	(revision b2bc25c4483f4c2b419d91d479f38c3f07ef4226)
+++ protocols/twitter/twitter_lib.c	(revision 508c340d1d12d3ca932001d7ee1dea1a4c81bf02)
@@ -130,5 +130,5 @@
 	args[0] = "cursor";
 	args[1] = g_strdup_printf ("%d", next_cursor);
-	twitter_http(TWITTER_FRIENDS_IDS_URL, twitter_http_get_friends_ids, ic, 0, td->user, td->pass, args, 2);
+	twitter_http(TWITTER_FRIENDS_IDS_URL, twitter_http_get_friends_ids, ic, 0, td->user, td->pass, td->oauth, args, 2);
 
 	g_free(args[1]);
@@ -396,5 +396,5 @@
 	}
 
-	twitter_http(TWITTER_HOME_TIMELINE_URL, twitter_http_get_home_timeline, ic, 0, td->user, td->pass, args, td->home_timeline_id ? 4 : 2);
+	twitter_http(TWITTER_HOME_TIMELINE_URL, twitter_http_get_home_timeline, ic, 0, td->user, td->pass, td->oauth, args, td->home_timeline_id ? 4 : 2);
 
 	g_free(args[1]);
@@ -620,5 +620,5 @@
 	args[1] = g_strdup_printf ("%d", next_cursor);
 
-	twitter_http(TWITTER_SHOW_FRIENDS_URL, twitter_http_get_statuses_friends, ic, 0, td->user, td->pass, args, 2);
+	twitter_http(TWITTER_SHOW_FRIENDS_URL, twitter_http_get_statuses_friends, ic, 0, td->user, td->pass, td->oauth, args, 2);
 
 	g_free(args[1]);
@@ -654,5 +654,5 @@
 	args[0] = "status";
 	args[1] = msg;
-	twitter_http(TWITTER_STATUS_UPDATE_URL, twitter_http_post_status, ic, 1, td->user, td->pass, args, 2);
+	twitter_http(TWITTER_STATUS_UPDATE_URL, twitter_http_post_status, ic, 1, td->user, td->pass, td->oauth, args, 2);
 //	g_free(args[1]);
 }
@@ -672,5 +672,5 @@
 	args[3] = msg;
 	// Use the same callback as for twitter_post_status, since it does basically the same.
-	twitter_http(TWITTER_DIRECT_MESSAGES_NEW_URL, twitter_http_post_status, ic, 1, td->user, td->pass, args, 4);
+	twitter_http(TWITTER_DIRECT_MESSAGES_NEW_URL, twitter_http_post_status, ic, 1, td->user, td->pass, td->oauth, args, 4);
 //	g_free(args[1]);
 //	g_free(args[3]);
