Changeset 39a939c for lib


Ignore:
Timestamp:
2011-07-31T14:55:00Z (8 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
e1c926f
Parents:
aa9f1ac
Message:

oauth2 changes to address http://twitter.com/Wilmer/status/96715400124968960

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/oauth2.c

    raa9f1ac r39a939c  
    3030struct oauth2_service oauth2_service_google =
    3131{
    32         "https://accounts.google.com/o/oauth2/",
     32        "https://accounts.google.com/o/oauth2/auth",
     33        "https://accounts.google.com/o/oauth2/token",
     34        "urn:ietf:wg:oauth:2.0:oob",
    3335        "783993391592.apps.googleusercontent.com",
    3436        "k5_EV4EQ7jEVCEk3WBwEFfuW",
     37};
     38struct 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",
    3545};
    3646
    3747char *oauth2_url( const struct oauth2_service *sp, const char *scope )
    3848{
    39         return g_strconcat( sp->base_url, "auth"
     49        return g_strconcat( sp->auth_url,
    4050                            "?scope=", scope,
    4151                            "&response_type=code"
    42                             "&redirect_uri=urn:ietf:wg:oauth:2.0:oob",
     52                            "&redirect_uri=", sp->redirect_url,
    4353                            "&client_id=", sp->consumer_key,
    4454                            NULL );
     
    6474        struct oauth2_access_token_data *cb_data;
    6575       
    66         if( !url_set( &url_p, sp->base_url ) )
     76        if( !url_set( &url_p, sp->token_url ) )
    6777                return 0;
    6878       
     
    7282        if( strcmp( auth_type, OAUTH2_AUTH_CODE ) == 0 )
    7383        {
    74                 oauth_params_add( &args, "redirect_uri", "urn:ietf:wg:oauth:2.0:oob" );
     84                oauth_params_add( &args, "redirect_uri", sp->redirect_url );
    7585                oauth_params_add( &args, "code", auth );
    7686        }
     
    8292        oauth_params_free( &args );
    8393       
    84         s = g_strdup_printf( "POST %s%s HTTP/1.0\r\n"
     94        s = g_strdup_printf( "POST %s HTTP/1.0\r\n"
    8595                             "Host: %s\r\n"
    8696                             "Content-Type: application/x-www-form-urlencoded\r\n"
     
    8898                             "Connection: close\r\n"
    8999                             "\r\n"
    90                              "%s", url_p.file, "token", url_p.host, strlen( args_s ), args_s );
     100                             "%s", url_p.file, url_p.host, strlen( args_s ), args_s );
    91101        g_free( args_s );
    92102       
  • lib/oauth2.h

    raa9f1ac r39a939c  
    2929struct oauth2_service
    3030{
    31         char *base_url;
     31        char *auth_url;
     32        char *token_url;
     33        char *redirect_url;
    3234        char *consumer_key;
    3335        char *consumer_secret;
     
    3739   accounts that have 2-factor authorization enabled. */
    3840extern struct oauth2_service oauth2_service_google;
     41
     42extern struct oauth2_service oauth2_service_facebook;
    3943
    4044#define OAUTH2_AUTH_CODE "authorization_code"
Note: See TracChangeset for help on using the changeset viewer.