If you use both
at the same time as shown below, the scopes settings from the tokensource is used.
The following works for cloudidentity api because the "books" api scope is simply ignored
configci, err := google.JWTConfigFromJSON(serviceAccountJSON, cloudidentity.CloudPlatformScope, cloudidentity.CloudIdentityGroupsReadonlyScope)
tsci := configci.TokenSource(ctx)
cisvc, err := cloudidentity.NewService(ctx, option.WithTokenSource(tsci), option.WithScopes("https://www.googleapis.com/auth/books"))
but if you invert it, you'll see a scopes error since the actual token from the config is used
configci, err := google.JWTConfigFromJSON(serviceAccountJSON, "https://www.googleapis.com/auth/books")
tsci := configci.TokenSource(ctx)
cisvc, err := cloudidentity.NewService(ctx, option.WithTokenSource(tsci), option.WithScopes(cloudidentity.CloudPlatformScope, cloudidentity.CloudIdentityGroupsReadonlyScope))
consider throwing an error if both are set
$ go version
go version go1.17.1 linux/amd64
module main
go 1.17
require (
golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c
google.golang.org/api v0.91.0
)
If you use both
at the same time as shown below, the scopes settings from the tokensource is used.
The following works for cloudidentity api because the "books" api scope is simply ignored
but if you invert it, you'll see a scopes error since the actual token from the config is used
consider throwing an error if both are set