- Timestamp:
- 2011-07-31T14:55:00Z (13 years ago)
- Branches:
- master
- Children:
- e1c926f
- Parents:
- aa9f1ac
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/oauth2.c
raa9f1ac r39a939c 30 30 struct oauth2_service oauth2_service_google = 31 31 { 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", 33 35 "783993391592.apps.googleusercontent.com", 34 36 "k5_EV4EQ7jEVCEk3WBwEFfuW", 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", 35 45 }; 36 46 37 47 char *oauth2_url( const struct oauth2_service *sp, const char *scope ) 38 48 { 39 return g_strconcat( sp-> base_url, "auth"49 return g_strconcat( sp->auth_url, 40 50 "?scope=", scope, 41 51 "&response_type=code" 42 "&redirect_uri= urn:ietf:wg:oauth:2.0:oob",52 "&redirect_uri=", sp->redirect_url, 43 53 "&client_id=", sp->consumer_key, 44 54 NULL ); … … 64 74 struct oauth2_access_token_data *cb_data; 65 75 66 if( !url_set( &url_p, sp-> base_url ) )76 if( !url_set( &url_p, sp->token_url ) ) 67 77 return 0; 68 78 … … 72 82 if( strcmp( auth_type, OAUTH2_AUTH_CODE ) == 0 ) 73 83 { 74 oauth_params_add( &args, "redirect_uri", "urn:ietf:wg:oauth:2.0:oob");84 oauth_params_add( &args, "redirect_uri", sp->redirect_url ); 75 85 oauth_params_add( &args, "code", auth ); 76 86 } … … 82 92 oauth_params_free( &args ); 83 93 84 s = g_strdup_printf( "POST %s %sHTTP/1.0\r\n"94 s = g_strdup_printf( "POST %s HTTP/1.0\r\n" 85 95 "Host: %s\r\n" 86 96 "Content-Type: application/x-www-form-urlencoded\r\n" … … 88 98 "Connection: close\r\n" 89 99 "\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 ); 91 101 g_free( args_s ); 92 102 -
lib/oauth2.h
raa9f1ac r39a939c 29 29 struct oauth2_service 30 30 { 31 char *base_url; 31 char *auth_url; 32 char *token_url; 33 char *redirect_url; 32 34 char *consumer_key; 33 35 char *consumer_secret; … … 37 39 accounts that have 2-factor authorization enabled. */ 38 40 extern struct oauth2_service oauth2_service_google; 41 42 extern struct oauth2_service oauth2_service_facebook; 39 43 40 44 #define OAUTH2_AUTH_CODE "authorization_code"
Note: See TracChangeset
for help on using the changeset viewer.