Changeset ce617f0
- Timestamp:
- 2011-03-27T14:09:55Z (14 years ago)
- Branches:
- master
- Children:
- f01bc6f
- Parents:
- ff94563
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/oauth.c
rff94563 rce617f0 108 108 static char *oauth_nonce() 109 109 { 110 unsigned char bytes[9]; 110 unsigned char bytes[21]; 111 char *ret = g_new0( char, sizeof( bytes) / 3 * 4 + 1 ); 111 112 112 113 random_bytes( bytes, sizeof( bytes ) ); 113 return base64_encode( bytes, sizeof( bytes ) ); 114 base64_encode_real( bytes, sizeof( bytes), (unsigned char*) ret, "0123456789" 115 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0A" ); 116 117 return ret; 114 118 } 115 119 -
protocols/twitter/twitter.c
rff94563 rce617f0 99 99 }; 100 100 101 static const struct oauth_service identica_oauth = 102 { 103 "http://identi.ca/api/oauth/request_token", 104 "http://identi.ca/api/oauth/access_token", 105 "https://identi.ca/api/oauth/authorize", 106 .consumer_key = "e147ff789fcbd8a5a07963afbb43f9da", 107 .consumer_secret = "c596267f277457ec0ce1ab7bb788d828", 108 }; 109 101 110 static gboolean twitter_oauth_callback( struct oauth_info *info ); 102 111 112 static const struct oauth_service *get_oauth_service( struct im_connection *ic ) 113 { 114 struct twitter_data *td = ic->proto_data; 115 116 if( strstr( td->url_host, "identi.ca" ) ) 117 return &identica_oauth; 118 else 119 return &twitter_oauth; 120 121 /* Could add more services, or allow configuring your own base URL + 122 API keys. */ 123 } 124 103 125 static void twitter_oauth_start( struct im_connection *ic ) 104 126 { … … 107 129 imcb_log( ic, "Requesting OAuth request token" ); 108 130 109 td->oauth_info = oauth_request_token( &twitter_oauth, twitter_oauth_callback, ic );131 td->oauth_info = oauth_request_token( get_oauth_service( ic ), twitter_oauth_callback, ic ); 110 132 111 133 /* We need help from the user to complete OAuth login, so don't time … … 263 285 td->user = acc->user; 264 286 if( strstr( acc->pass, "oauth_token=" ) ) 265 td->oauth_info = oauth_from_string( acc->pass, &twitter_oauth);287 td->oauth_info = oauth_from_string( acc->pass, get_oauth_service( ic ) ); 266 288 267 289 sprintf( name, "%s_%s", td->prefix, acc->user );
Note: See TracChangeset
for help on using the changeset viewer.