當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Client.GetUserData方法代碼示例

本文整理匯總了Golang中github.com/RangelReale/osin.Client.GetUserData方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.GetUserData方法的具體用法?Golang Client.GetUserData怎麽用?Golang Client.GetUserData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/RangelReale/osin.Client的用法示例。


在下文中一共展示了Client.GetUserData方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: CreateClient

func (s *Storage) CreateClient(c osin.Client) error {
	userData, err := dataToString(c.GetUserData())
	if err != nil {
		return err
	}
	_, err = s.db.Exec("INSERT INTO client (id, secret, redirect_uri, extra) VALUES ($1, $2, $3, $4)", c.GetId(), c.GetSecret(), c.GetRedirectUri(), userData)
	return err
}
開發者ID:galeone,項目名稱:osin-storage,代碼行數:8,代碼來源:postgres.go

示例2: UpdateClient

func (s *Storage) UpdateClient(c osin.Client) error {
	userData, err := dataToString(c.GetUserData())
	if err != nil {
		return err
	}

	_, err = s.db.Exec("UPDATE client SET (secret, redirect_uri, extra) = ($2, $3, $4) WHERE id=$1", c.GetId(), c.GetSecret(), c.GetRedirectUri(), userData)
	return err
}
開發者ID:galeone,項目名稱:osin-storage,代碼行數:9,代碼來源:postgres.go

示例3: UpdateClient

// UpdateClient updates the client (identified by it's id) and replaces the values with the values of client.
func (s *Storage) UpdateClient(c osin.Client) error {
	data, err := assertToString(c.GetUserData())
	if err != nil {
		return err
	}

	if _, err := s.db.Exec("UPDATE client SET (secret, redirect_uri, extra) = ($2, $3, $4) WHERE id=$1", c.GetId(), c.GetSecret(), c.GetRedirectUri(), data); err != nil {
		return errors.New(err)
	}
	return nil
}
開發者ID:guitou4573,項目名稱:osin-storage,代碼行數:12,代碼來源:postgres.go

示例4: CreateClient

// CreateClient stores the client in the database and returns an error, if something went wrong.
func (s *Storage) CreateClient(c osin.Client) error {
	data, err := assertToString(c.GetUserData())
	if err != nil {
		return err
	}

	if _, err := s.db.Exec("INSERT INTO client (id, secret, redirect_uri, extra) VALUES ($1, $2, $3, $4)", c.GetId(), c.GetSecret(), c.GetRedirectUri(), data); err != nil {
		return errors.New(err)
	}
	return nil
}
開發者ID:guitou4573,項目名稱:osin-storage,代碼行數:12,代碼來源:postgres.go

示例5: SetClient

func (store *SQLStorage) SetClient(client osin.Client) error {
	stmt, err := store.authDB.Prepare("INSERT INTO clients(id, secret, redirect_uri, user_data) VALUES(?, ?, ?, ?)")

	// Marshal user data into string
	userDataStr, err := setUserData(client.GetUserData())
	if err != nil {
		return err
	}

	_, err = stmt.Exec(client.GetId(), client.GetSecret(), client.GetRedirectUri(), userDataStr)
	return err
}
開發者ID:felipeweb,項目名稱:osin-sql-storage,代碼行數:12,代碼來源:sqlstorage.go

示例6: CreateClient

// CreateClient creates a new OAuth2 Client
func (s *OAuth2Storage) CreateClient(c osin.Client, name string) (*OAuth2Client, error) {
	client := OAuth2Client{
		Name:        name,
		RedirectURI: c.GetRedirectUri(),
		Secret:      c.GetSecret(),
		UserID:      c.GetUserData().(uint64),
	}

	if err := Db().Create(&client); err != nil {
		return nil, err
	}

	return &client, nil
}
開發者ID:nerdzeu,項目名稱:nerdz-api,代碼行數:15,代碼來源:oauth2.go

示例7: CreateClient

// CreateClient stores the client in the database and returns an error, if something went wrong.
func (s *Storage) CreateClient(c osin.Client) error {
	data, err := assertToString(c.GetUserData())
	if err != nil {
		return err
	}
	args := map[string]interface{}{
		"id":       c.GetId(),
		"secret":   c.GetSecret(),
		"redirect": c.GetRedirectUri(),
		"extra":    data,
	}
	nstmt, err := s.db.PrepareNamed("INSERT INTO client (id, secret, redirect_uri, extra) VALUES (:id, :secret, :redirect, :extra)")
	if err != nil {
		return errors.New(err)
	}
	_, err = nstmt.Exec(args)

	return nil
}
開發者ID:guitou4573,項目名稱:osin-storage,代碼行數:20,代碼來源:mysql.go

示例8: UpdateClient

// UpdateClient update client with id c.GetId()
func (s *OAuth2Storage) UpdateClient(c osin.Client) (*OAuth2Client, error) {
	var numericID uint64
	var err error
	if numericID, err = strconv.ParseUint(c.GetId(), 10, 64); err != nil {
		return nil, fmt.Errorf("invalid client_id: %s", c.GetId())
	}

	client := OAuth2Client{
		ID:          numericID,
		RedirectURI: c.GetRedirectUri(),
		Secret:      c.GetSecret(),
		UserID:      c.GetUserData().(uint64),
	}

	if err := Db().Updates(&client); err != nil {
		return nil, err
	}

	return &client, nil
}
開發者ID:nerdzeu,項目名稱:nerdz-api,代碼行數:21,代碼來源:oauth2.go

示例9: UpdateClient

// UpdateClient updates the client (identified by it's id) and replaces the values with the values of client.
func (s *Storage) UpdateClient(c osin.Client) error {
	data, err := assertToString(c.GetUserData())
	if err != nil {
		return err
	}
	args := map[string]interface{}{
		"id":       c.GetId(),
		"secret":   c.GetSecret(),
		"redirect": c.GetRedirectUri(),
		"extra":    data,
	}

	nstmt, err := s.db.PrepareNamed("UPDATE client SET (secret, redirect_uri, extra) = (:secret, :redirect, :extra) WHERE idclient=:id")
	if err != nil {
		return err
	}
	_, err = nstmt.Exec(args)

	return nil
}
開發者ID:guitou4573,項目名稱:osin-storage,代碼行數:21,代碼來源:mysql.go


注:本文中的github.com/RangelReale/osin.Client.GetUserData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。