func newTokenSourceFromPath(
	ctx context.Context,
	path string,
	scope string,
) (ts oauth2.TokenSource, err error) {
	contents, err := ioutil.ReadFile(path)
	if err != nil {
		err = fmt.Errorf("ReadFile(%q): %w", path, err)
		return
	}
	jwtConfig, err := google.JWTConfigFromJSON(contents, scope)
	if err != nil {
		err = fmt.Errorf("JWTConfigFromJSON: %w", err)
		return
	}
	ts = jwtConfig.TokenSource(ctx)
	return
}
Create token source from the JSON file at the supplide path.
package auth
import (
	"context"
	"fmt"
	"io/ioutil"
	"github.com/jacobsa/gcloud/gcs"
	"golang.org/x/oauth2"
	"golang.org/x/oauth2/google"
)