diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2011-12-19 13:54:49 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2011-12-19 13:54:49 +0100 |
commit | 36533bf6bfc01f56afd6a8cd7bd3dfa9de87297b (patch) | |
tree | 88d6198cba41269ff74c59dda317e2a559d5236e /protocols/jabber | |
parent | 4be0e3458a001a1c2eb3dd0074d7fd65260f2e6f (diff) |
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.)
Diffstat (limited to 'protocols/jabber')
-rw-r--r-- | protocols/jabber/sasl.c | 24 |
1 files changed, 11 insertions, 13 deletions
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 ); |