diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2011-12-18 22:56:44 +0100 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2011-12-18 22:56:44 +0100 | 
| commit | 64b663524a465efb7707a2c634be97b9fb6f963b (patch) | |
| tree | d9f7aea9f8e75a4f00de06a1965eaad16581cd2f /protocols/jabber/jabber.c | |
| parent | 18c6d369d777a1d38ef450f868c22de1d0ebba2d (diff) | |
Restructured and updated code a little bit to support new-style (much better
and "proper" OAuth2) Facebook OAuth support. (And, add wl.offline scope to get
tokens that don't expire after an hour.)
Diffstat (limited to 'protocols/jabber/jabber.c')
| -rw-r--r-- | protocols/jabber/jabber.c | 23 | 
1 files changed, 17 insertions, 6 deletions
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index bf849e2a..50ee6f2d 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -151,16 +151,27 @@ static void jabber_login( account_t *acc )  		else  			jd->oauth2_service = &oauth2_service_google; -		/* For the first login with OAuth, we have to authenticate via the browser. -		   For subsequent logins, exchange the refresh token for a valid access -		   token (even though the last one maybe didn't expire yet). */ -		if( strncmp( acc->pass, "refresh_token=", 14 ) != 0 ) +		/* First see if we have a refresh token, in which case any +		   access token we *might* have has probably expired already +		   anyway. */ +		if( strstr( acc->pass, "refresh_token=" ) ) +		{ +			sasl_oauth2_refresh( ic, acc->pass + 14 ); +		} +		/* If we don't have a refresh token, let's hope the access +		   token is still usable. */ +		else if( strstr( acc->pass, "access_token=" ) ) +		{ +			sasl_oauth2_load_access_token( ic ); +			jabber_connect( ic ); +		} +		/* If we don't have any, start the OAuth process now. Don't +		   even open an XMPP connection yet. */ +		else  		{  			sasl_oauth2_init( ic );  			ic->flags |= OPT_SLOW_LOGIN;  		} -		else -			sasl_oauth2_refresh( ic, acc->pass + 14 );  	}  	else  		jabber_connect( ic );  | 
