- Timestamp:
- 2011-12-18T19:25:44Z (13 years ago)
- Branches:
- master
- Children:
- 64b6635
- Parents:
- 6e9ae72
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/oauth2.c
r6e9ae72 r18c6d36 28 28 #include "url.h" 29 29 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 ) 30 char *oauth2_url( const struct oauth2_service *sp ) 48 31 { 49 32 return g_strconcat( sp->auth_url, 50 "?scope=", s cope,33 "?scope=", sp->scope, 51 34 "&response_type=code" 52 35 "&redirect_uri=", sp->redirect_url, … … 121 104 char *atoken = NULL, *rtoken = NULL; 122 105 106 if( getenv( "BITLBEE_DEBUG" ) && req->reply_body ) 107 printf( "%s\n", req->reply_body ); 108 123 109 if( req->status_code == 200 ) 124 110 { 125 111 atoken = oauth2_json_dumb_get( req->reply_body, "access_token" ); 126 112 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 ); 127 115 } 128 116 cb_data->func( cb_data->data, atoken, rtoken ); -
lib/oauth2.h
r6e9ae72 r18c6d36 32 32 char *token_url; 33 33 char *redirect_url; 34 char *scope; 34 35 char *consumer_key; 35 36 char *consumer_secret; 36 37 }; 37 38 /* Currently suitable for authenticating to Google Talk only, and only for39 accounts that have 2-factor authorization enabled. */40 extern struct oauth2_service oauth2_service_google;41 42 extern struct oauth2_service oauth2_service_facebook;43 38 44 39 #define OAUTH2_AUTH_CODE "authorization_code" … … 47 42 /* Generate a URL the user should open in his/her browser to get an 48 43 authorization code. */ 49 char *oauth2_url( const struct oauth2_service *sp , const char *scope);44 char *oauth2_url( const struct oauth2_service *sp ); 50 45 51 46 /* Exchanges an auth code or refresh token for an access token.
Note: See TracChangeset
for help on using the changeset viewer.