Ejemplo n.º 1
0
func (s *Storage) GetClient(id string) (osin.Client, error) {
	row := s.db.QueryRow("SELECT id, secret, redirect_uri, extra FROM client WHERE id=$1 LIMIT 1", id)
	var c osin.DefaultClient
	var extra string
	if err := row.Scan(&c.Id, &c.Secret, &c.RedirectUri, &extra); err != nil {
		return nil, err
	}
	c.UserData = extra
	return &c, nil
}
Ejemplo n.º 2
0
// GetClient loads the client by id
func (s *Storage) GetClient(id string) (osin.Client, error) {
	row := s.db.QueryRow("SELECT id, secret, redirect_uri, extra FROM client WHERE id=$1", id)
	var c osin.DefaultClient
	var extra string

	if err := row.Scan(&c.Id, &c.Secret, &c.RedirectUri, &extra); err == sql.ErrNoRows {
		return nil, pkg.ErrNotFound
	} else if err != nil {
		return nil, errors.New(err)
	}
	c.UserData = extra
	return &c, nil
}
Ejemplo n.º 3
0
// GetClient loads the client by id
func (s *Storage) GetClient(id string) (osin.Client, error) {
	args := map[string]interface{}{
		"id": id,
	}

	nstmt, err := s.db.PrepareNamed("SELECT idclient, secret, redirect_uri, extra FROM client WHERE idclient=:id")
	if err != nil {
		return nil, err
	}
	row := nstmt.QueryRowx(args)
	var c osin.DefaultClient
	var extra string

	if err := row.Scan(&c.Id, &c.Secret, &c.RedirectUri, &extra); err == sql.ErrNoRows {
		return nil, errors.New("not found")
	} else if err != nil {
		return nil, errors.New(err)
	}
	c.UserData = extra
	return &c, nil
}