Ejemplo n.º 1
0
func GetClientByID(tx *sql.Tx, id string) (*osin.DefaultClient, error) {
	client, err := datastore.GetClientByID(tx, id)
	if err != nil {
		return nil, err
	}

	c := &osin.DefaultClient{
		Id:          client.Id,
		Secret:      client.Secret,
		RedirectUri: client.RedirectUri,
	}

	return c, nil
}
Ejemplo n.º 2
0
func CreateAccess(tx *sql.Tx, data *osin.AccessData) error {
	client, err := datastore.GetClientByID(tx, data.Client.GetId())
	if err != nil {
		return err
	}

	access := &model.AccessData{
		UID:             utils.NewUUID(),
		ClientID:        client.UID,
		AuthorizeDataID: "",
		AccessDataID:    "",
		AccessToken:     data.AccessToken,
		RefreshToken:    data.RefreshToken,
		ExpiresIn:       data.ExpiresIn,
		Scope:           data.Scope,
		RedirectUri:     data.RedirectUri,
		CreatedAt:       data.CreatedAt,
	}

	Log.Debug("%+v", access)
	err = datastore.CreateAccess(tx, access)
	return err
}