source: lib/oauth2.h @ 2f99f23

3.4.1
Last change on this file since 2f99f23 was 5ebff60, checked in by dequis <dx@…>, at 2015-02-20T22:50:54Z

Reindent everything to K&R style with tabs

Used uncrustify, with the configuration file in ./doc/uncrustify.cfg

Commit author set to "Indent <please@…>" so that it's easier to
skip while doing git blame.

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[57b4525]1/***************************************************************************\
2*                                                                           *
3*  BitlBee - An IRC to IM gateway                                           *
[4a5d885]4*  Simple OAuth2 client (consumer) implementation.                          *
[57b4525]5*                                                                           *
[c153808]6*  Copyright 2010-2013 Wilmer van der Gaast <wilmer@gaast.net>              *
[57b4525]7*                                                                           *
8*  This program is free software; you can redistribute it and/or modify     *
9*  it under the terms of the GNU General Public License as published by     *
10*  the Free Software Foundation; either version 2 of the License, or        *
11*  (at your option) any later version.                                      *
12*                                                                           *
13*  This program is distributed in the hope that it will be useful,          *
14*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
15*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
16*  GNU General Public License for more details.                             *
17*                                                                           *
18*  You should have received a copy of the GNU General Public License along  *
19*  with this program; if not, write to the Free Software Foundation, Inc.,  *
20*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.              *
21*                                                                           *
22\***************************************************************************/
23
[4a5d885]24/* Implementation mostly based on my experience with writing the previous OAuth
25   module, and from http://code.google.com/apis/accounts/docs/OAuth2.html . */
[57b4525]26
[5ebff60]27typedef void (*oauth2_token_callback)(gpointer data, const char *atoken,
28                                      const char *rtoken, const char *error);
[57b4525]29
[5ebff60]30struct oauth2_service {
[39a939c]31        char *auth_url;
32        char *token_url;
33        char *redirect_url;
[18c6d36]34        char *scope;
[57b4525]35        char *consumer_key;
36        char *consumer_secret;
37};
38
[4a5d885]39#define OAUTH2_AUTH_CODE "authorization_code"
40#define OAUTH2_AUTH_REFRESH "refresh_token"
[57b4525]41
[4a5d885]42/* Generate a URL the user should open in his/her browser to get an
43   authorization code. */
[5ebff60]44char *oauth2_url(const struct oauth2_service *sp);
[57b4525]45
[4a5d885]46/* Exchanges an auth code or refresh token for an access token.
47   auth_type is one of the two OAUTH2_AUTH_.. constants above. */
[5ebff60]48int oauth2_access_token(const struct oauth2_service *sp,
49                        const char *auth_type, const char *auth,
50                        oauth2_token_callback func, gpointer data);
Note: See TracBrowser for help on using the repository browser.