185
case EMPATHY_SASL_MECHANISM_GOOGLE:
186
empathy_sasl_auth_google_async (data->channel,
187
goa_account_get_identity (goa_object_peek_account (data->goa_object)),
188
access_token, auth_cb, data);
186
192
g_assert_not_reached ();
199
got_password_passwd_cb (GObject *source,
200
GAsyncResult *result,
203
GoaPasswordBased *password = (GoaPasswordBased *) source;
204
AuthData *data = user_data;
206
GError *error = NULL;
208
if (!goa_password_based_call_get_password_finish (password,
209
&passwd, result, &error))
211
DEBUG ("Failed to get password: %s", error->message);
213
g_clear_error (&error);
217
DEBUG ("Got password for %s", tp_proxy_get_object_path (data->account));
219
empathy_sasl_auth_password_async (data->channel, passwd, auth_cb, data);
193
224
ensure_credentials_cb (GObject *source,
194
225
GAsyncResult *result,
195
226
gpointer user_data)
197
228
AuthData *data = user_data;
198
229
GoaAccount *goa_account = (GoaAccount *) source;
199
230
GoaOAuth2Based *oauth2;
231
GoaPasswordBased *password;
232
EmpathySaslMechanism mech;
233
gboolean supports_password;
201
235
GError *error = NULL;
212
/* We support only oaut2 */
246
/* We prefer oauth2, if available */
213
247
oauth2 = goa_object_get_oauth2_based (data->goa_object);
216
DEBUG ("GoaObject does not implement oauth2");
221
DEBUG ("Goa daemon has credentials for %s, get the access token",
222
tp_proxy_get_object_path (data->account));
224
goa_oauth2_based_call_get_access_token (oauth2, NULL,
225
got_oauth2_access_token_cb, data);
227
g_object_unref (oauth2);
248
mech = empathy_sasl_channel_select_mechanism (data->channel);
249
if (oauth2 != NULL && mech != EMPATHY_SASL_MECHANISM_PASSWORD)
251
DEBUG ("Goa daemon has credentials for %s, get the access token",
252
tp_proxy_get_object_path (data->account));
254
goa_oauth2_based_call_get_access_token (oauth2, NULL,
255
got_oauth2_access_token_cb, data);
257
g_object_unref (oauth2);
261
/* Else we use the password */
262
password = goa_object_get_password_based (data->goa_object);
263
supports_password = empathy_sasl_channel_supports_mechanism (data->channel,
264
"X-TELEPATHY-PASSWORD");
265
if (password != NULL && supports_password)
267
DEBUG ("Goa daemon has credentials for %s, get the password",
268
tp_proxy_get_object_path (data->account));
270
/* arg_id is currently unused */
271
goa_password_based_call_get_password (password, "", NULL,
272
got_password_passwd_cb, data);
274
g_object_unref (password);
278
DEBUG ("GoaObject does not implement oauth2 or password");
352
404
mech = empathy_sasl_channel_select_mechanism (channel);
353
405
return mech == EMPATHY_SASL_MECHANISM_FACEBOOK ||
354
mech == EMPATHY_SASL_MECHANISM_WLM;
406
mech == EMPATHY_SASL_MECHANISM_WLM ||
407
mech == EMPATHY_SASL_MECHANISM_GOOGLE ||
408
mech == EMPATHY_SASL_MECHANISM_PASSWORD;