Changeset 18c6d36 for lib/oauth2.c


Ignore:
Timestamp:
2011-12-18T19:25:44Z (8 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
64b6635
Parents:
6e9ae72
Message:

More generic OAuth support now. Should work well for all GTalk accounts now
and somewhat for MS Messenger. The fb part needs different parsing of the
authorize request, and possibly some other work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/oauth2.c

    r6e9ae72 r18c6d36  
    2828#include "url.h"
    2929
    30 struct oauth2_service oauth2_service_google =
    31 {
    32         "https://accounts.google.com/o/oauth2/auth",
    33         "https://accounts.google.com/o/oauth2/token",
    34         "urn:ietf:wg:oauth:2.0:oob",
    35         "783993391592.apps.googleusercontent.com",
    36         "6C-Zgf7Tr7gEQTPlBhMUgo7R",
    37 };
    38 struct oauth2_service oauth2_service_facebook =
    39 {
    40         "https://www.facebook.com/dialog/oauth",
    41         "https://graph.facebook.com/oauth/access_token",
    42         "http://www.bitlbee.org/main.php/fb.html",
    43         "126828914005625",
    44         "4b100f0f244d620bf3f15f8b217d4c32",
    45 };
    46 
    47 char *oauth2_url( const struct oauth2_service *sp, const char *scope )
     30char *oauth2_url( const struct oauth2_service *sp )
    4831{
    4932        return g_strconcat( sp->auth_url,
    50                             "?scope=", scope,
     33                            "?scope=", sp->scope,
    5134                            "&response_type=code"
    5235                            "&redirect_uri=", sp->redirect_url,
     
    121104        char *atoken = NULL, *rtoken = NULL;
    122105       
     106        if( getenv( "BITLBEE_DEBUG" ) && req->reply_body )
     107                printf( "%s\n", req->reply_body );
     108       
    123109        if( req->status_code == 200 )
    124110        {
    125111                atoken = oauth2_json_dumb_get( req->reply_body, "access_token" );
    126112                rtoken = oauth2_json_dumb_get( req->reply_body, "refresh_token" );
     113                if( getenv( "BITLBEE_DEBUG" ) )
     114                        printf( "Extracted atoken=%s rtoken=%s\n", atoken, rtoken );
    127115        }
    128116        cb_data->func( cb_data->data, atoken, rtoken );
Note: See TracChangeset for help on using the changeset viewer.