source: lib/oauth2.h @ 57b4525

Last change on this file since 57b4525 was 57b4525, checked in by Wilmer van der Gaast <wilmer@…>, at 2011-07-22T18:29:25Z

Nothing useful yet, this just generates an auth URL. Things to do: Ability
to process the answer. This is hard because the GTalk server will time out
very quickly which means we lose our state/scope/etc. (And the ability to
even receive the answer, at least if I'd do this the same way the Twitter
module does it.)

And then, get the access token and use it, of course. :-)

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[57b4525]1/***************************************************************************\
2*                                                                           *
3*  BitlBee - An IRC to IM gateway                                           *
4*  Simple OAuth client (consumer) implementation.                           *
5*                                                                           *
6*  Copyright 2010-2011 Wilmer van der Gaast <wilmer@gaast.net>              *
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
24struct oauth2_info;
25
26/* Callback function called twice during the access token request process.
27   Return FALSE if something broke and the process must be aborted. */
28typedef gboolean (*oauth_cb)( struct oauth2_info * );
29
30struct oauth2_info
31{
32        const struct oauth_service *sp;
33       
34        oauth_cb func;
35        void *data;
36       
37        struct http_request *http;
38       
39//      char *auth_url;
40//      char *request_token;
41       
42//      char *token;
43//      char *token_secret;
44//      GSList *params;
45};
46
47struct oauth2_service
48{
49        char *base_url;
50        char *consumer_key;
51        char *consumer_secret;
52};
53
54extern struct oauth2_service oauth2_service_google;
55
56/* http://oauth.net/core/1.0a/#auth_step1 (section 6.1)
57   Request an initial anonymous token which can be used to construct an
58   authorization URL for the user. This is passed to the callback function
59   in a struct oauth2_info. */
60char *oauth2_url( const struct oauth2_service *sp, const char *scope );
61
62/* http://oauth.net/core/1.0a/#auth_step3 (section 6.3)
63   The user gets a PIN or so which we now exchange for the final access
64   token. This is passed to the callback function in the same
65   struct oauth2_info. */
66gboolean oauth2_access_token( const char *pin, struct oauth2_info *st );
67
68/* Shouldn't normally be required unless the process is aborted by the user. */
69void oauth2_info_free( struct oauth2_info *info );
Note: See TracBrowser for help on using the repository browser.