@@ -83,17 +83,21 @@ func GrantAdditionalScopes(grantScopes string) auth.AccessTokenScope {
8383
8484 var accessScopes []string // the scopes for access control, but not for general information
8585 for _ , scope := range strings .Split (grantScopes , " " ) {
86- if ! slices .Contains (generalScopesSupported , scope ) {
86+ if scope != "" && ! slices .Contains (generalScopesSupported , scope ) {
8787 accessScopes = append (accessScopes , scope )
8888 }
8989 }
9090
9191 // since version 1.22, access tokens grant full access to the API
9292 // with this access is reduced only if additional scopes are provided
93- // TODO: if there are invalid access scopes, then it is treated as "all", but would we really always treat invalid scopes as "all"?
94- accessTokenScope := auth .AccessTokenScope (strings .Join (accessScopes , "," ))
95- if normalizedAccessTokenScope , err := accessTokenScope .Normalize (); err == nil && normalizedAccessTokenScope != "" {
96- return normalizedAccessTokenScope
93+ if len (accessScopes ) > 0 {
94+ accessTokenScope := auth .AccessTokenScope (strings .Join (accessScopes , "," ))
95+ if normalizedAccessTokenScope , err := accessTokenScope .Normalize (); err == nil {
96+ return normalizedAccessTokenScope
97+ }
98+ // TODO: if there are invalid access scopes (err != nil),
99+ // then it is treated as "all", maybe in the future we should make it stricter to return an error
100+ // at the moment, to avoid breaking 1.22 behavior, invalid tokens are also treated as "all"
97101 }
98102 // fallback, empty access scope is treated as "all" access
99103 return auth .AccessTokenScopeAll
0 commit comments