code: func (s *Service) IntermediateStorage(c context.Context, rw bool) (storage.Storage, error) {
  	cfg := s.ServiceConfig()
  	if cfg.GetStorage() == nil {
  		log.Errorf(c, "Missing storage configuration.")
  		return nil, ErrInvalidConfig
  	}
  
  	btcfg := cfg.GetStorage().GetBigtable()
  	if btcfg == nil {
  		log.Errorf(c, "Missing BigTable storage configuration")
  		return nil, ErrInvalidConfig
  	}
  
  	// Determine our scopes.
  	scopes := bigtable.StorageReadOnlyScopes
  	if rw {
  		scopes = bigtable.StorageScopes
  	}
  
  	// Initialize RPC credentials.
  	ts, err := serverAuth.GetTokenSource(c, serverAuth.AsSelf, serverAuth.WithScopes(scopes...))
  	if err != nil {
  		return nil, err
  	}
  	client, err := cloudBT.NewClient(c, btcfg.Project, btcfg.Instance,
  		option.WithUserAgent(s.getUserAgent()), option.WithTokenSource(ts))
  	if err != nil {
  		return nil, err
  	}
  	return &bigtable.Storage{
  		Client:   client,
  		LogTable: btcfg.LogTableName,
  	}, nil
  }
docs: // IntermediateStorage instantiates the configured intermediate Storage
  // instance.
  //
  // If "rw" is true, Read/Write access will be requested. Otherwise, read-only
  // access will be requested.