github stytchauth/stytch-go v8.1.0

latest releases: v16.35.0, v16.34.0, v16.33.0...
2 years ago

Changes

  • Deprecated the b2c.Users.GetPending method. Use b2c.Users.SearchAll or b2c.Users.Search instead. See the upgrade guide below for an example change.

Fixes

  • Add the B2B Passwords.Delete method
  • Add the B2B Sessions.GetJWKS method
  • Add the B2B PasswordsAuthenticateParams.OrganizationID field

Upgrade Guide

Existing calls to b2c.Users.GetPending will continue to work until the next major version of stytch-go. To prepare for its removal, change all uses of b2c.Users.GetPending to b2c.Users.SearchAll. Here's an example migration:

Before

ctx := context.TODO()

params := &b2c.UsersGetPendingParams{
    Limit: 200,
}

res, err := client.Users.GetPending(ctx, params)
if err != nil {
	panic(err)
}

// TODO: Do something with res.Users

for res.HasMore {
	params.StartingAfterID = res.StartingAfterID

	res, err = client.Users.GetPending(ctx, params)
	if err != nil {
		panic(err)
	}

	// TODO: Do something with res.Users
}

After

ctx := context.TODO()

params := &b2c.UsersSearchParams{
    Limit: 200,
	Query: &b2c.UsersSearchQuery{
		Operator: b2c.UserSearchOperatorOR,
		Operands: []json.Marshaler{
			b2c.UsersSearchQueryStatusFilter{Status: "pending"},
		},
	},
}

pendingUsers := client.Users.SearchAll(params)

for pendingUsers.HasNext() {
	users, err := pendingUsers.Next(ctx)
	if err != nil {
		panic(err)
	}

	// TODO: Do something with users
}

If you prefer to keep the same iteration pattern that GetPending has, use Search directly instead:

ctx := context.TODO()

params := &b2c.UsersSearchParams{
    Limit: 200,
	Query: &b2c.UsersSearchQuery{
		Operator: b2c.UserSearchOperatorOR,
		Operands: []json.Marshaler{
			b2c.UsersSearchQueryStatusFilter{Status: "pending"},
		},
	},
}

res, err := client.Users.Search(ctx, params)
if err != nil {
	panic(err)
}

// TODO: Do something with res.Results

for res.ResultsMetadata.NextCursor != "" {
	params.Cursor = res.ResultsMetadata.NextCursor

	res, err = client.Users.Search(ctx, params)
	if err != nil {
		panic(err)
	}

	// TODO: Do something with res.Results
}

Don't miss a new stytch-go release

NewReleases is sending notifications on new releases.