diff options
Diffstat (limited to 'lib/oauth.c')
-rw-r--r-- | lib/oauth.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/oauth.c b/lib/oauth.c index 4c93cbf4..8012c37a 100644 --- a/lib/oauth.c +++ b/lib/oauth.c @@ -424,3 +424,30 @@ char *oauth_http_header( struct oauth_info *oi, const char *method, const char * return ret ? g_string_free( ret, FALSE ) : NULL; } + +char *oauth_to_string( struct oauth_info *oi ) +{ + GSList *params = NULL; + char *ret; + + oauth_params_add( ¶ms, "oauth_token", oi->token ); + oauth_params_add( ¶ms, "oauth_token_secret", oi->token_secret ); + ret = oauth_params_string( params ); + oauth_params_free( ¶ms ); + + return ret; +} + +struct oauth_info *oauth_from_string( char *in, struct oauth_service *sp ) +{ + struct oauth_info *oi = g_new0( struct oauth_info, 1 ); + GSList *params = NULL; + + oauth_params_parse( ¶ms, in ); + oi->token = g_strdup( oauth_params_get( ¶ms, "oauth_token" ) ); + oi->token_secret = g_strdup( oauth_params_get( ¶ms, "oauth_token_secret" ) ); + oauth_params_free( ¶ms ); + oi->sp = sp; + + return oi; +} |