Commit dd51571d authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Update to Facebook Graph API v9.0, remove unused Facebook profile request fields.

parent f32e880b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
- Make metrics prefix configurable, default to fixed value.
- Build with Go 1.15.5 release.
- Skip logging Lua errors raised by explicit runtime calls to the `error({msg, code})` built-in.
- Update to Facebook Graph API v9.0.
- Facebook authentication no longer requires access to gender, locale, and timezone data.

### Fixed
- Better handling of SSL connections in development configurations.
+6 −9
Original line number Diff line number Diff line
@@ -81,9 +81,6 @@ type FacebookProfile struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
	Gender   string  `json:"gender"`
	Locale   string  `json:"locale"`
	Timezone float64 `json:"timezone"`
}

type facebookPagingCursors struct {
@@ -194,8 +191,8 @@ dAUK75fDiSKxH3fzvc1D1PFMqT+1i4SvZPLQFCE=
func (c *Client) GetFacebookProfile(ctx context.Context, accessToken string) (*FacebookProfile, error) {
	c.logger.Debug("Getting Facebook profile", zap.String("token", accessToken))

	path := "https://graph.facebook.com/v5.0/me?access_token=" + url.QueryEscape(accessToken) +
		"&fields=" + url.QueryEscape("name,email,gender,locale,timezone")
	path := "https://graph.facebook.com/v9.0/me?access_token=" + url.QueryEscape(accessToken) +
		"&fields=" + url.QueryEscape("name,email")
	var profile FacebookProfile
	err := c.request(ctx, "facebook profile", path, nil, &profile)
	if err != nil {
@@ -213,7 +210,7 @@ func (c *Client) GetFacebookFriends(ctx context.Context, accessToken string) ([]
	after := ""
	for {
		// In FB Graph API 2.0+ this only returns friends that also use the same app.
		path := "https://graph.facebook.com/v5.0/me/friends?access_token=" + url.QueryEscape(accessToken)
		path := "https://graph.facebook.com/v9.0/me/friends?access_token=" + url.QueryEscape(accessToken)
		if after != "" {
			path += "&after=" + after
		}