From 95b8486f28e69400f2117ab14bc96b2fdb088436 Mon Sep 17 00:00:00 2001
From: Samuel Tallent <samuelbtallent@gmail.com>
Date: Tue, 12 Mar 2019 22:59:35 -0500
Subject: [PATCH 1/3] Update gothic.go

Fix issue where defer Logout() is taking place prior to the determining a session exists
---
 gothic/gothic.go | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gothic/gothic.go b/gothic/gothic.go
index bea87d963..e8f5ca322 100644
--- a/gothic/gothic.go
+++ b/gothic/gothic.go
@@ -149,7 +149,6 @@ as either "provider" or ":provider".
 See https://github.com/markbates/goth/examples/main.go to see this in action.
 */
 var CompleteUserAuth = func(res http.ResponseWriter, req *http.Request) (goth.User, error) {
-	defer Logout(res, req)
 	if !keySet && defaultStore == Store {
 		fmt.Println("goth/gothic: no SESSION_SECRET environment variable is set. The default cookie store is not available and any calls will fail. Ignore this warning if you are using a different store.")
 	}
@@ -168,7 +167,7 @@ var CompleteUserAuth = func(res http.ResponseWriter, req *http.Request) (goth.Us
 	if err != nil {
 		return goth.User{}, err
 	}
-
+	defer Logout(res, req)
 	sess, err := provider.UnmarshalSession(value)
 	if err != nil {
 		return goth.User{}, err

From b1b23dd0e6cb8bde486c4dfea066435e9317701b Mon Sep 17 00:00:00 2001
From: samueltallent <samuelbtallent@gmail.com>
Date: Wed, 18 Dec 2019 19:42:05 -0600
Subject: [PATCH 2/3] Restore defer

---
 gothic/gothic.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gothic/gothic.go b/gothic/gothic.go
index d0ffebf01..ea4e1e0db 100644
--- a/gothic/gothic.go
+++ b/gothic/gothic.go
@@ -149,6 +149,7 @@ as either "provider" or ":provider".
 See https://github.com/markbates/goth/examples/main.go to see this in action.
 */
 var CompleteUserAuth = func(res http.ResponseWriter, req *http.Request) (goth.User, error) {
+	defer Logout(res, req)
 	if !keySet && defaultStore == Store {
 		fmt.Println("goth/gothic: no SESSION_SECRET environment variable is set. The default cookie store is not available and any calls will fail. Ignore this warning if you are using a different store.")
 	}
@@ -167,7 +168,7 @@ var CompleteUserAuth = func(res http.ResponseWriter, req *http.Request) (goth.Us
 	if err != nil {
 		return goth.User{}, err
 	}
-	defer Logout(res, req)
+
 	sess, err := provider.UnmarshalSession(value)
 	if err != nil {
 		return goth.User{}, err

From 39c06df3223afb3ecf7a2261710fdd032e83236b Mon Sep 17 00:00:00 2001
From: samueltallent <samuelbtallent@gmail.com>
Date: Wed, 18 Dec 2019 20:00:36 -0600
Subject: [PATCH 3/3] Updated scopes for spotify provider

---
 providers/spotify/spotify.go | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/providers/spotify/spotify.go b/providers/spotify/spotify.go
index 6b77350f6..c44fca656 100644
--- a/providers/spotify/spotify.go
+++ b/providers/spotify/spotify.go
@@ -19,6 +19,9 @@ const (
 )
 
 const (
+	// ScopePlaylistReadPrivate seeks permission to read
+	// a user's collaborative playlists.
+	ScopePlaylistReadCollaborative = "playlist-read-collaborative"
 	// ScopePlaylistReadPrivate seeks permission to read
 	// a user's private playlists.
 	ScopePlaylistReadPrivate = "playlist-read-private"
@@ -34,7 +37,7 @@ const (
 	// ScopeUserFollowRead seeks read access to the list of
 	// artists and other users that a user follows.
 	ScopeUserFollowRead = "user-follow-read"
-	// ScopeUserLibraryModify seeks write/delete acess to a
+	// ScopeUserLibraryModify seeks write/delete access to a
 	// user's "Your Music" library.
 	ScopeUserLibraryModify = "user-library-modify"
 	// ScopeUserLibraryRead seeks read access to a user's
@@ -46,6 +49,25 @@ const (
 	// ScopeUserReadEmail seeks read access to a user's
 	// email address.
 	ScopeUserReadEmail = "user-read-email"
+	// ScopeUGCImageUpload seeks write access to user-provided images.
+	ScopeUGCImageUpload = "ugc-image-upload"
+	// ScopeUserReadPlaybackState seeks read access to a user’s player state.
+	ScopeUserReadPlaybackState = "user-read-playback-state"
+	// ScopeUserModifyPlaybackState seeks write access to a user’s playback state
+	ScopeUserModifyPlaybackState = "user-modify-playback-state"
+	// ScopeUserReadCurrentlyPlaying seeks read access to a user’s currently playing track
+	ScopeUserReadCurrentlyPlaying = "user-read-currently-playing"
+	// ScopeStreaming seeks to control playback of a Spotify track.
+	// This scope is currently available to the Web Playback SDK.
+	// The user must have a Spotify Premium account.
+	ScopeStreaming = "streaming"
+	// ScopeAppRemoteControl seeks remote control playback of Spotify.
+	// This scope is currently available to Spotify iOS and Android SDKs.
+	ScopeAppRemoteControl = "app-remote-control"
+	// ScopeUserTopRead seeks read access to a user's top artists and tracks.
+	ScopeUserTopRead = "user-top-read"
+	// ScopeUserReadRecentlyPlayed seeks read access to a user’s recently played tracks.
+	ScopeUserReadRecentlyPlayed = "user-read-recently-played"
 )
 
 // New creates a new Spotify provider and sets up important connection details.