aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/oauth.h1
-rw-r--r--protocols/jabber/sasl.c24
2 files changed, 12 insertions, 13 deletions
diff --git a/lib/oauth.h b/lib/oauth.h
index b7388503..50adc95c 100644
--- a/lib/oauth.h
+++ b/lib/oauth.h
@@ -95,4 +95,5 @@ void oauth_params_add( GSList **params, const char *key, const char *value );
void oauth_params_parse( GSList **params, char *in );
void oauth_params_free( GSList **params );
char *oauth_params_string( GSList *params );
+void oauth_params_set( GSList **params, const char *key, const char *value );
const char *oauth_params_get( GSList **params, const char *key );
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 );