aboutsummaryrefslogtreecommitdiffstats
path: root/lib/oauth2.h
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2011-12-26 11:51:19 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2011-12-26 11:51:19 +0100
commit5f40da79f78e444f08387ce53da1b2e471c8552f (patch)
treeceded3c147f55b819e11503e91cc4d9e75bbcd43 /lib/oauth2.h
parent96f954df218e81f5580257c319b91217dac2f4bf (diff)
parent644b8080349d7d42ca89946acc207592fd0acc2d (diff)
Merging oauth-xmpp branch, which adds support for OAuth2 authentication
against some XMPP services (Google Talk, Facebook and Microsoft's MSN-XMPP gateway).
Diffstat (limited to 'lib/oauth2.h')
-rw-r--r--lib/oauth2.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/oauth2.h b/lib/oauth2.h
new file mode 100644
index 00000000..c8d18963
--- /dev/null
+++ b/lib/oauth2.h
@@ -0,0 +1,50 @@
+/***************************************************************************\
+* *
+* BitlBee - An IRC to IM gateway *
+* Simple OAuth2 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. *
+* *
+\***************************************************************************/
+
+/* Implementation mostly based on my experience with writing the previous OAuth
+ module, and from http://code.google.com/apis/accounts/docs/OAuth2.html . */
+
+typedef void (*oauth2_token_callback)( gpointer data, const char *atoken, const char *rtoken );
+
+struct oauth2_service
+{
+ char *auth_url;
+ char *token_url;
+ char *redirect_url;
+ char *scope;
+ char *consumer_key;
+ char *consumer_secret;
+};
+
+#define OAUTH2_AUTH_CODE "authorization_code"
+#define OAUTH2_AUTH_REFRESH "refresh_token"
+
+/* Generate a URL the user should open in his/her browser to get an
+ authorization code. */
+char *oauth2_url( const struct oauth2_service *sp );
+
+/* Exchanges an auth code or refresh token for an access token.
+ auth_type is one of the two OAUTH2_AUTH_.. constants above. */
+int oauth2_access_token( const struct oauth2_service *sp,
+ const char *auth_type, const char *auth,
+ oauth2_token_callback func, gpointer data );