From cae47918f1670cbc38db51f164fa889af92ce120 Mon Sep 17 00:00:00 2001 From: mrpkin <93314186+mrpkin@users.noreply.github.com> Date: Sat, 24 Dec 2022 17:57:23 +0530 Subject: [PATCH 1/3] Update scope for instagram Instagram has changed the scope to user_profile and user_media. This commit helps to update it --- providers/instagram/instagram.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/providers/instagram/instagram.go b/providers/instagram/instagram.go index b4703dc44..0901406fd 100644 --- a/providers/instagram/instagram.go +++ b/providers/instagram/instagram.go @@ -147,11 +147,12 @@ func newConfig(p *Provider, scopes []string) *oauth2.Config { TokenURL: tokenURL, }, Scopes: []string{ - "basic", + "user_profile", }, } defaultScopes := map[string]struct{}{ - "basic": {}, + "user_profile": {}, + "user_media": {} } for _, scope := range scopes { From 65b34cfe1d7e6043430f252b927c41820acf13dd Mon Sep 17 00:00:00 2001 From: mrpkin <93314186+mrpkin@users.noreply.github.com> Date: Sat, 24 Dec 2022 17:58:39 +0530 Subject: [PATCH 2/3] Update instagram.go --- providers/instagram/instagram.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/instagram/instagram.go b/providers/instagram/instagram.go index 0901406fd..356952697 100644 --- a/providers/instagram/instagram.go +++ b/providers/instagram/instagram.go @@ -152,7 +152,7 @@ func newConfig(p *Provider, scopes []string) *oauth2.Config { } defaultScopes := map[string]struct{}{ "user_profile": {}, - "user_media": {} + "user_media": {}, } for _, scope := range scopes { From 9653a9ddbea763e254726734ff2afbe16636d2a9 Mon Sep 17 00:00:00 2001 From: mrpkin <93314186+mrpkin@users.noreply.github.com> Date: Sun, 25 Dec 2022 01:55:50 +0530 Subject: [PATCH 3/3] Update Instagram API and model parsing https://developers.facebook.com/docs/instagram-basic-display-api/reference/user --- providers/instagram/instagram.go | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/providers/instagram/instagram.go b/providers/instagram/instagram.go index 356952697..1d8aaa574 100644 --- a/providers/instagram/instagram.go +++ b/providers/instagram/instagram.go @@ -19,7 +19,7 @@ import ( var ( authURL = "https://api.instagram.com/oauth/authorize/" tokenURL = "https://api.instagram.com/oauth/access_token" - endPointProfile = "https://api.instagram.com/v1/users/self/" + endPointProfile = "https://graph.instagram.com/v15.0/me" ) // New creates a new Instagram provider, and sets up important connection details. @@ -110,22 +110,10 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { } func userFromReader(reader io.Reader, user *goth.User) error { - u := struct { - Data struct { - ID string `json:"id"` - UserName string `json:"username"` - FullName string `json:"full_name"` - ProfilePicture string `json:"profile_picture"` - Bio string `json:"bio"` - Website string `json:"website"` - Counts struct { - Media int `json:"media"` - Follows int `json:"follows"` - FollowedBy int `json:"followed_by"` - } `json:"counts"` - } `json:"data"` - }{} - err := json.NewDecoder(reader).Decode(&u) + var u struct { + ID string `json:"id"` + UserName string `json:"username"` + } err := json.NewDecoder(reader).Decode(&u) if err != nil { return err }