Example #1
0
func pubsubContext(ctx context.Context, projectID string) (context.Context, error) {
	httpClient, err := google.DefaultClient(ctx, pubsub.ScopePubSub)
	if err != nil {
		return nil, err
	}
	return cloud.WithContext(ctx, projectID, httpClient), nil
}
Example #2
0
func newPubSubService(ctx context.Context, config pubsubConfig, client *http.Client) (pubSubService, error) {
	if config.project == "" {
		return nil, errors.New("pubsub: you must supply a project")
	}
	return &pubSubServiceImpl{
		ctx: cloud.WithContext(ctx, config.project, client),
	}, nil
}
Example #3
0
func cloudContext(projectID string) (context.Context, error) {
	ctx := context.Background()
	httpClient, err := google.DefaultClient(ctx, storage.ScopeFullControl, pubsub.ScopePubSub)
	if err != nil {
		return nil, err
	}
	return cloud.WithContext(ctx, projectID, httpClient), nil
}
func handleFunc(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	c.Infof("env: %v", os.Environ())
	client, err := serviceaccount.NewClient(c, "https://www.googleapis.com/auth/devstorage.read_write")
	c.Infof("client=%+v err=%+v", client, err)
	cc := cloud.WithContext(context.Background(), appengine.AppID(c), client)
	bucket, err := storage.BucketInfo(cc, appengine.AppID(c)+".appspot.com")
	c.Infof("bucket=%+v err=%+v", bucket, err)
}
Example #5
0
// Context returns an cloud.Context based on the receiver Config.
func (c *Config) Context(ctx context.Context) (context.Context, error) {
	if c.ProjectID == "" {
		return nil, errors.New("oauth2 configuration missing project ID")
	}
	cl, err := c.Client(ctx)
	if err != nil {
		return nil, err
	}
	return cloud.WithContext(ctx, c.ProjectID, cl), nil
}
Example #6
0
func (cfg *AppengineStoreConfig) Generate(c context.Context) files.FileStore {
	hc := &http.Client{
		Transport: &oauth2.Transport{
			Source: google.AppEngineTokenSource(c, storage.ScopeFullControl),
			Base:   &urlfetch.Transport{Context: c},
		},
	}
	ctx := cloud.WithContext(c, appengine.AppID(c), hc)
	return &AppengineStore{cfg, ctx}
}
Example #7
0
// Get an auth context for logging RPC.
func cloudAuthContext(r *http.Request) (context.Context, error) {
	c := appengine.NewContext(r)

	hc := &http.Client{
		Transport: &oauth2.Transport{
			Source: google.AppEngineTokenSource(c, logging.Scope),
			Base:   &urlfetch.Transport{Context: c},
		},
	}
	return cloud.WithContext(c, appengine.AppID(c), hc), nil
}
func cloudAuthContext(r *http.Request) (context.Context, error) {
	c := appengine.NewContext(r)

	hc := &http.Client{
		Transport: &oauth2.Transport{
			Source: google.AppEngineTokenSource(c, storage.ScopeFullControl),
			Base:   &urlfetch.Transport{Context: c},
		},
	}
	return cloud.WithContext(c, "rule110-go", hc), nil

}
Example #9
0
func (d *driver) context(context ctx.Context) context.Context {
	return cloud.WithContext(context, dummyProjectID, d.client)
}
Example #10
0
func CloudContext(parent context.Context) context.Context {
	if parent == nil {
		return cloud.NewContext(projID, cloudClient)
	}
	return cloud.WithContext(parent, projID, cloudClient)
}
func (this *SalesforceOpportunityEvents) context(ctx context.Context) context.Context {
	return cloud.WithContext(ctx, this.projectID, this.conf.Client(oauth2.NoContext))
}