Index: lib/Makefile
===================================================================
--- lib/Makefile	(revision a01049810d7101b8c0014aa7b36826fc95f944a5)
+++ lib/Makefile	(revision 57b4525653972dc23c8c5ca5ffaa7e44fad64ee9)
@@ -13,5 +13,5 @@
 
 # [SH] Program variables
-objects = arc.o base64.o $(DES) $(EVENT_HANDLER) ftutil.o http_client.o ini.o md5.o misc.o oauth.o proxy.o sha1.o $(SSL_CLIENT) url.o xmltree.o
+objects = arc.o base64.o $(DES) $(EVENT_HANDLER) ftutil.o http_client.o ini.o md5.o misc.o oauth.o oauth2.o proxy.o sha1.o $(SSL_CLIENT) url.o xmltree.o
 
 LFLAGS += -r
Index: lib/oauth2.c
===================================================================
--- lib/oauth2.c	(revision 57b4525653972dc23c8c5ca5ffaa7e44fad64ee9)
+++ lib/oauth2.c	(revision 57b4525653972dc23c8c5ca5ffaa7e44fad64ee9)
@@ -0,0 +1,42 @@
+/***************************************************************************\
+*                                                                           *
+*  BitlBee - An IRC to IM gateway                                           *
+*  Simple OAuth client (consumer) implementation.                           *
+*                                                                           *
+*  Copyright 2010-2011 Wilmer van der Gaast <wilmer@gaast.net>              *
+*                                                                           *
+*  This program is free software; you can redistribute it and/or modify     *
+*  it under the terms of the GNU General Public License as published by     *
+*  the Free Software Foundation; either version 2 of the License, or        *
+*  (at your option) any later version.                                      *
+*                                                                           *
+*  This program is distributed in the hope that it will be useful,          *
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
+*  GNU General Public License for more details.                             *
+*                                                                           *
+*  You should have received a copy of the GNU General Public License along  *
+*  with this program; if not, write to the Free Software Foundation, Inc.,  *
+*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.              *
+*                                                                           *
+\***************************************************************************/
+
+#include <glib.h>
+#include "oauth2.h"
+
+struct oauth2_service oauth2_service_google =
+{
+	"https://accounts.google.com/o/oauth2/",
+	"783993391592.apps.googleusercontent.com",
+	"k5_EV4EQ7jEVCEk3WBwEFfuW",
+};
+
+char *oauth2_url( const struct oauth2_service *sp, const char *scope )
+{
+	return g_strconcat( sp->base_url, "auth"
+	                    "?scope=", scope,
+	                    "&response_type=code"
+	                    "&redirect_uri=urn:ietf:wg:oauth:2.0:oob",
+	                    "&client_id=", sp->consumer_key,
+	                    NULL );
+}
Index: lib/oauth2.h
===================================================================
--- lib/oauth2.h	(revision 57b4525653972dc23c8c5ca5ffaa7e44fad64ee9)
+++ lib/oauth2.h	(revision 57b4525653972dc23c8c5ca5ffaa7e44fad64ee9)
@@ -0,0 +1,69 @@
+/***************************************************************************\
+*                                                                           *
+*  BitlBee - An IRC to IM gateway                                           *
+*  Simple OAuth client (consumer) implementation.                           *
+*                                                                           *
+*  Copyright 2010-2011 Wilmer van der Gaast <wilmer@gaast.net>              *
+*                                                                           *
+*  This program is free software; you can redistribute it and/or modify     *
+*  it under the terms of the GNU General Public License as published by     *
+*  the Free Software Foundation; either version 2 of the License, or        *
+*  (at your option) any later version.                                      *
+*                                                                           *
+*  This program is distributed in the hope that it will be useful,          *
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
+*  GNU General Public License for more details.                             *
+*                                                                           *
+*  You should have received a copy of the GNU General Public License along  *
+*  with this program; if not, write to the Free Software Foundation, Inc.,  *
+*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.              *
+*                                                                           *
+\***************************************************************************/
+
+struct oauth2_info;
+
+/* Callback function called twice during the access token request process.
+   Return FALSE if something broke and the process must be aborted. */
+typedef gboolean (*oauth_cb)( struct oauth2_info * );
+
+struct oauth2_info
+{
+	const struct oauth_service *sp;
+	
+	oauth_cb func;
+	void *data;
+	
+	struct http_request *http;
+	
+//	char *auth_url;
+//	char *request_token;
+	
+//	char *token;
+//	char *token_secret;
+//	GSList *params;
+};
+
+struct oauth2_service
+{
+	char *base_url;
+	char *consumer_key;
+	char *consumer_secret;
+};
+
+extern struct oauth2_service oauth2_service_google;
+
+/* 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 oauth2_info. */
+char *oauth2_url( const struct oauth2_service *sp, const char *scope );
+
+/* 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 oauth2_info. */
+gboolean oauth2_access_token( const char *pin, struct oauth2_info *st );
+
+/* Shouldn't normally be required unless the process is aborted by the user. */
+void oauth2_info_free( struct oauth2_info *info );
