Changeset bf57cd1


Ignore:
Timestamp:
2011-12-19T00:17:38Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
4be0e34
Parents:
9b0ad7e
Message:

Facebook OAuth2 should now be fully usable.

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/oauth.c

    r9b0ad7e rbf57cd1  
    134134        GSList *l, *n;
    135135       
     136        if( params == NULL )
     137                return NULL;
     138       
    136139        for( l = *params; l; l = n )
    137140        {
     
    157160        int key_len = strlen( key );
    158161        GSList *l;
     162       
     163        if( params == NULL )
     164                return NULL;
    159165       
    160166        for( l = *params; l; l = l->next )
  • lib/oauth2.c

    r9b0ad7e rbf57cd1  
    103103        struct oauth2_access_token_data *cb_data = req->data;
    104104        char *atoken = NULL, *rtoken = NULL;
     105        const char *content_type;
    105106       
    106107        if( getenv( "BITLBEE_DEBUG" ) && req->reply_body )
    107108                printf( "%s\n", req->reply_body );
    108109       
    109         if( req->status_code == 200 )
     110        content_type = get_rfc822_header( req->reply_headers, "Content-Type", 0 );
     111       
     112        if( req->status_code != 200 )
     113        {
     114        }
     115        else if( strstr( content_type, "application/json" ) )
    110116        {
    111117                atoken = oauth2_json_dumb_get( req->reply_body, "access_token" );
     
    113119                if( getenv( "BITLBEE_DEBUG" ) )
    114120                        printf( "Extracted atoken=%s rtoken=%s\n", atoken, rtoken );
     121        }
     122        else
     123        {
     124                /* Facebook use their own odd format here, seems to be URL-encoded. */
     125                GSList *p_in = NULL;
     126               
     127                oauth_params_parse( &p_in, req->reply_body );
     128                atoken = g_strdup( oauth_params_get( &p_in, "access_token" ) );
     129                rtoken = g_strdup( oauth_params_get( &p_in, "refresh_token" ) );
     130                oauth_params_free( &p_in );
    115131        }
    116132        cb_data->func( cb_data->data, atoken, rtoken );
Note: See TracChangeset for help on using the changeset viewer.