From 36533bf6bfc01f56afd6a8cd7bd3dfa9de87297b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 19 Dec 2011 13:54:49 +0100 Subject: When updating the XMPP password field with OAuth data, try harder to preserve existing data. (Like refresh tokens which we'll need again on next login.) --- protocols/jabber/sasl.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'protocols/jabber/sasl.c') diff --git a/protocols/jabber/sasl.c b/protocols/jabber/sasl.c index 8727212f..06dda8a8 100644 --- a/protocols/jabber/sasl.c +++ b/protocols/jabber/sasl.c @@ -527,6 +527,7 @@ static void sasl_oauth2_got_token( gpointer data, const char *access_token, cons { struct im_connection *ic = data; struct jabber_data *jd; + GSList *auth = NULL; if( g_slist_find( jabber_connections, ic ) == NULL ) return; @@ -539,19 +540,16 @@ static void sasl_oauth2_got_token( gpointer data, const char *access_token, cons imc_logout( ic, TRUE ); return; } - if( refresh_token != NULL ) - { - g_free( ic->acc->pass ); - ic->acc->pass = g_strdup_printf( "refresh_token=%s", refresh_token ); - } - /* Should do this, but only in the Facebook case where we get an access - token that never expires. Shouldn't overwrite a refresh token with - an access token. - else - { - g_free( ic->acc->pass ); - ic->acc->pass = g_strdup_printf( "access_token=%s", access_token ); - } */ + + oauth_params_parse( &auth, ic->acc->pass ); + if( refresh_token ) + oauth_params_set( &auth, "refresh_token", refresh_token ); + if( access_token ) + oauth_params_set( &auth, "access_token", access_token ); + + g_free( ic->acc->pass ); + ic->acc->pass = oauth_params_string( auth ); + oauth_params_free( &auth ); g_free( jd->oauth2_access_token ); jd->oauth2_access_token = g_strdup( access_token ); -- cgit v1.2.3