• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang osin.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/RangelReale/osin.Client的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Client类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: DeleteClient

// DeleteClient deletes given client
func (s *RethinkDBStorage) DeleteClient(c osin.Client) error {
	result, err := r.Table(clientsTable).Filter(r.Row.Field("Id").Eq(c.GetId())).Run(s.session)
	if err != nil {
		return err
	}
	defer result.Close()

	var clientMap map[string]interface{}
	err = result.One(&clientMap)
	if err != nil {
		return err
	}

	_, err = r.Table(clientsTable).Get(clientMap["id"]).Delete().RunWrite(s.session)
	return err
}
开发者ID:ahmet,项目名称:osin-rethinkdb,代码行数:17,代码来源:rethinkdb_storage.go


示例6: 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


示例7: 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


示例8: CopyFrom

func (d *DefaultClient) CopyFrom(client osin.Client) {
	d.Id = client.GetId()
	d.Secret = client.GetSecret()
	d.RedirectUri = client.GetRedirectUri()
	d.UserData = nil
	//	d.UserData = client.GetUserData()
}
开发者ID:imtheoperator,项目名称:osin-datastore,代码行数:7,代码来源:default_client.go


示例9: CreateClient

// CreateClient adds new client.
// This is not a part of interface and as so, it's never used in osin flow.
// However can be really usefull for applications to add new clients.
func (receiver *Storage) CreateClient(client osin.Client) error {
	data, err := json.Marshal(client)
	if err != nil {
		return err
	}

	params := &dynamodb.PutItemInput{
		Item: map[string]*dynamodb.AttributeValue{
			"id": {
				S: aws.String(client.GetId()),
			},
			"json": {
				S: aws.String(string(data)),
			},
		},
		TableName: aws.String(receiver.config.ClientTable),
	}

	if _, err := receiver.db.PutItem(params); err != nil {
		return err
	}

	return nil
}
开发者ID:uniplaces,项目名称:osin-dynamodb,代码行数:27,代码来源:osindynamodb.go


示例10: 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


示例11: 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


示例12: 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


示例13: SetClient

func (s *MySQLStorage) SetClient(id string, client osin.Client) error {
	c := &osin.DefaultClient{
		Id:          client.GetId(),
		Secret:      client.GetSecret(),
		RedirectUri: client.GetRedirectUri(),
	}

	err := Transact(db.DB, func(tx *sql.Tx) error {
		var err error
		err = service.CreateClient(tx, c)
		return err
	})
	return err
}
开发者ID:gregory90,项目名称:go-oauth2,代码行数:14,代码来源:mysql.go


示例14: SetClient

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

	_, err = stmt.Exec(client.GetId(), client.GetSecret(), client.GetRedirectUri())
	return err
}
开发者ID:credli,项目名称:osin-sql-storage,代码行数:6,代码来源:sqlstorage.go


示例15: getClient

func getClient(t *testing.T, store storage.Storage, set osin.Client) {
	client, err := store.GetClient(set.GetId())
	require.Nil(t, err)
	require.EqualValues(t, set, client)
}
开发者ID:bagocius,项目名称:osin-storage,代码行数:5,代码来源:postgres_test.go


示例16: createOauthClient

func createOauthClient(w http.ResponseWriter, r *http.Request) {
	var responseMessage []byte
	code := 200

	if r.Method == "POST" {
		decoder := json.NewDecoder(r.Body)
		var newOauthClient NewClientRequest
		err := decoder.Decode(&newOauthClient)

		if err != nil {
			responseMessage = []byte(E_SYSTEM_ERROR)
			code = 500
			log.Error("Couldn't decode body")
			log.Error(err)

		}

		u5, err := uuid.NewV4()
		cleanSting := strings.Replace(u5.String(), "-", "", -1)
		u5Secret, err := uuid.NewV4()
		secret := base64.StdEncoding.EncodeToString([]byte(u5Secret.String()))

		newClient := osin.Client{}
		newClient.Id = cleanSting
		newClient.RedirectUri = newOauthClient.ClientRedirectURI
		newClient.Secret = secret

		storageID := createOauthClientStorageID(newOauthClient.APIID, newClient.Id)
		storeErr := genericOsinStorage.SetClient(storageID, &newClient, true)

		if storeErr != nil {
			log.Error("Failed to save new client data: ", storeErr)
			responseMessage = createError("Failure in storing client data.")
		}

		reportableClientData := OAuthClient{
			ClientID:          newClient.Id,
			ClientSecret:      newClient.Secret,
			ClientRedirectURI: newClient.RedirectUri,
		}

		responseMessage, err = json.Marshal(&reportableClientData)

		if err != nil {
			log.Error("Marshalling failed")
			log.Error(err)
			responseMessage = []byte(E_SYSTEM_ERROR)
			code = 500
		} else {
			log.WithFields(logrus.Fields{
				"key": newClient.Id,
			}).Info("New OAuth Client registered successfully.")
		}

	} else {
		code = 405
		responseMessage = createError("Method not supported")
	}

	w.WriteHeader(code)
	fmt.Fprintf(w, string(responseMessage))
}
开发者ID:joshrendek,项目名称:tyk,代码行数:62,代码来源:api.go


示例17: removeClient

func removeClient(t *testing.T, store storage.Storage, set osin.Client) {
	require.Nil(t, store.RemoveClient(set.GetId()))
}
开发者ID:bagocius,项目名称:osin-storage,代码行数:3,代码来源:postgres_test.go



注:本文中的github.com/RangelReale/osin.Client类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang example.HandleLoginPage函数代码示例发布时间:2022-05-28
下一篇:
Golang osin.AuthorizeRequest类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap