Ejemplo n.º 1
0
func (c *AlphaWingController) InitGoogleService() revel.Result {
	config := &models.ServiceAccountConfig{
		ClientEmail: Conf.ServiceAccountClientEmail,
		PrivateKey:  Conf.ServiceAccountPrivateKey,
		Scope:       []string{drive.DriveScope},
	}

	token, err := models.GetServiceAccountToken(config)
	if err != nil {
		panic(err)
	}

	s, err := models.NewGoogleService(token)
	if err != nil {
		panic(err)
	}
	c.GoogleService = s

	capacityInfo, err := s.GetCapacityInfo()
	if err != nil {
		panic(err)
	}
	c.RenderArgs["capacityInfo"] = capacityInfo

	return nil
}
Ejemplo n.º 2
0
func (c *AlphaWingController) userGoogleService() (*models.GoogleService, error) {
	token, err := c.token()
	if err != nil {
		return nil, err
	}

	s, err := models.NewGoogleService(token)
	if err != nil {
		return nil, err
	}

	return s, nil
}