From d38f6bb0abd7e0b144d7bd3c8cfcf06318fe20e7 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 5 Jul 2021 14:45:26 +0100 Subject: [PATCH] gphotos: fix read only scope not being used properly Before this change the read only scope was being ignored and rclone was asking for a read-write scope. https://forum.rclone.org/t/google-photos-copy-sync-errors/25153 --- backend/googlephotos/googlephotos.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/googlephotos/googlephotos.go b/backend/googlephotos/googlephotos.go index 7019eee29..d78af509f 100644 --- a/backend/googlephotos/googlephotos.go +++ b/backend/googlephotos/googlephotos.go @@ -53,6 +53,7 @@ const ( minSleep = 10 * time.Millisecond scopeReadOnly = "https://www.googleapis.com/auth/photoslibrary.readonly" scopeReadWrite = "https://www.googleapis.com/auth/photoslibrary" + scopeAccess = 2 // position of access scope in list ) var ( @@ -61,7 +62,7 @@ var ( Scopes: []string{ "openid", "profile", - scopeReadWrite, + scopeReadWrite, // this must be at position scopeAccess }, Endpoint: google.Endpoint, ClientID: rcloneClientID, @@ -89,9 +90,9 @@ func init() { case "": // Fill in the scopes if opt.ReadOnly { - oauthConfig.Scopes[0] = scopeReadOnly + oauthConfig.Scopes[scopeAccess] = scopeReadOnly } else { - oauthConfig.Scopes[0] = scopeReadWrite + oauthConfig.Scopes[scopeAccess] = scopeReadWrite } return oauthutil.ConfigOut("warning", &oauthutil.Options{ OAuth2Config: oauthConfig,