source: lib/oauth.h @ 78a2f1e

Last change on this file since 78a2f1e was c42e8b9, checked in by Wilmer van der Gaast <wilmer@…>, at 2010-04-26T22:40:11Z

OAuth, it lives!

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/***************************************************************************\
2*                                                                           *
3*  BitlBee - An IRC to IM gateway                                           *
4*  Simple OAuth client (consumer) implementation.                           *
5*                                                                           *
6*  Copyright 2010 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
24/* http://oauth.net/core/1.0a/ */
25
26struct oauth_info;
27typedef void (*oauth_cb)( struct oauth_info * );
28
29typedef enum
30{
31        OAUTH_INIT,
32        OAUTH_REQUEST_TOKEN,
33        OAUTH_ACCESS_TOKEN,
34} oauth_stage_t;
35
36struct oauth_info
37{
38        oauth_stage_t stage;
39       
40        oauth_cb func;
41        void *data;
42       
43        struct http_request *http;
44       
45        char *auth_params;
46        char *request_token;
47       
48        char *access_token;
49};
50
51/* http://oauth.net/core/1.0a/#auth_step1 (section 6.1)
52   Request an initial anonymous token which can be used to construct an
53   authorization URL for the user. This is passed to the callback function
54   in a struct oauth_info. */
55void *oauth_request_token( const char *url, oauth_cb func, void *data );
56
57/* http://oauth.net/core/1.0a/#auth_step3 (section 6.3)
58   The user gets a PIN or so which we now exchange for the final access
59   token. This is passed to the callback function in the same
60   struct oauth_info. */
61void *oauth_access_token( const char *url, const char *pin, struct oauth_info *st );
62
63/* http://oauth.net/core/1.0a/#anchor12 (section 7)
64   Generate an OAuth Authorization: HTTP header. access_token should be
65   saved/fetched using the functions above. args can be a string with
66   whatever's going to be in the POST body of the request. GET args will
67   automatically be grabbed from url. */
68char *oauth_http_header( char *access_token, const char *method, const char *url, char *args );
Note: See TracBrowser for help on using the repository browser.