[gnome-online-accounts/wip/rishi/facebook: 9/14] facebook: Make it work with Graph API > 2.3
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/wip/rishi/facebook: 9/14] facebook: Make it work with Graph API > 2.3
- Date: Wed, 2 Aug 2017 19:21:12 +0000 (UTC)
commit 32860066727d771e3761d960646f93d614c48dba
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Aug 2 19:19:31 2017 +0200
facebook: Make it work with Graph API > 2.3
Ever since version 2.3 of the Graph API was retired on 8th July, it
stopped including the "email" in the JSON when a GET request is issued
against https://graph.facebook.com/me?access_token=...
Now it needs to be explicitly asked for. The changelog [1] for version
2.4 says:
"To try to improve performance on mobile networks, Nodes and Edges
in v2.4 requires that you explicitly request the field(s) you need
for your GET requests. For example, GET /v2.4/me/feed no longer
includes likes and comments by default, but GET
/v2.4/me/feed?fields=comments,likes will return the data."
It seems that "id" is always included, but we mention it anyway.
The "username" fallback that was added in commit 10c77f1713be2215 has
been removed because requesting it leads to:
{
"error": {
"message": "(#12) username field is deprecated for versions v2.0
and higher",
"type": "OAuthException",
"code": 12,
"fbtrace_id": "AJYNXiIv00W"
}
}
We will have to investigate whether we need a new fallback for the
presentation identity.
[1] https://developers.facebook.com/docs/apps/changelog
https://bugzilla.gnome.org/show_bug.cgi?id=785726
src/goabackend/goafacebookprovider.c | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/src/goabackend/goafacebookprovider.c b/src/goabackend/goafacebookprovider.c
index 688074e..b4d9cdd 100644
--- a/src/goabackend/goafacebookprovider.c
+++ b/src/goabackend/goafacebookprovider.c
@@ -162,7 +162,10 @@ get_identity_sync (GoaOAuth2Provider *oauth2_provider,
proxy = rest_proxy_new ("https://graph.facebook.com/me", FALSE);
call = rest_proxy_new_call (proxy);
rest_proxy_call_set_method (call, "GET");
- rest_proxy_call_add_param (call, "access_token", access_token);
+ rest_proxy_call_add_params (call,
+ "access_token", access_token,
+ "fields", "id,email",
+ NULL);
if (!rest_proxy_call_sync (call, error))
goto out;
@@ -209,20 +212,19 @@ get_identity_sync (GoaOAuth2Provider *oauth2_provider,
_("Could not parse response"));
goto out;
}
-
- id = g_strdup (json_object_get_string_member (json_object, "id"));
-
- if (json_object_has_member (json_object, "email"))
- presentation_identity = g_strdup (json_object_get_string_member (json_object, "email"));
- else if (json_object_has_member (json_object, "username"))
- presentation_identity = g_strdup (json_object_get_string_member (json_object, "username"));
- else
+ if (!json_object_has_member (json_object, "email"))
{
- g_warning ("Did not find email or username in JSON data");
- g_set_error (error, GOA_ERROR, GOA_ERROR_FAILED, _("Could not parse response"));
+ g_warning ("Did not find email in JSON data");
+ g_set_error (error,
+ GOA_ERROR,
+ GOA_ERROR_FAILED,
+ _("Could not parse response"));
goto out;
}
+ id = g_strdup (json_object_get_string_member (json_object, "id"));
+ presentation_identity = g_strdup (json_object_get_string_member (json_object, "email"));
+
ret = id;
id = NULL;
if (out_presentation_identity != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]