Skip to content

Commit

Permalink
Update readme to include B2B Examples (#185)
Browse files Browse the repository at this point in the history
* Update readme to include B2B Examples

* Remove project uuids
  • Loading branch information
bgier-stytch authored Jul 12, 2024
1 parent 2139d95 commit 86b6fcd
Showing 1 changed file with 70 additions and 1 deletion.
71 changes: 70 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ $ go get github.com/stytchauth/stytch-go/v12
You can find your API credentials in the [Stytch Dashboard](https://stytch.com/dashboard/api-keys).

This client library supports all Stytch's live products:

### B2C

- [x] [Email Magic Links](https://stytch.com/docs/api/send-by-email)
- [x] [Embeddable Magic Links](https://stytch.com/docs/guides/magic-links/embeddable-magic-links/api)
- [x] [OAuth logins](https://stytch.com/docs/guides/oauth/idp-overview)
Expand All @@ -28,8 +31,18 @@ This client library supports all Stytch's live products:
- [x] [Passwords](https://stytch.com/docs/guides/passwords/api)
- [x] [M2M](https://stytch.com/docs/api/m2m-client)

### B2B

- [x] [Organizations](https://stytch.com/docs/b2b/api/organization-object)
- [x] [Members](https://stytch.com/docs/b2b/api/member-object)
- [x] [Email Magic Links](https://stytch.com/docs/b2b/api/send-login-signup-email)
- [x] [OAuth logins](https://stytch.com/docs/b2b/api/oauth-google-start)
- [x] [Session Management](https://stytch.com/docs/b2b/api/session-object)
- [x] [Single-Sign On](https://stytch.com/docs/b2b/api/sso-authenticate-start)
- [x] [Discovery](https://stytch.com/docs/b2b/api/discovered-organization-object)
- [x] [Passwords](https://stytch.com/docs/b2b/api/passwords-authenticate)

### Example usage
### Example B2C usage
Create an API client:
```go
import (
Expand Down Expand Up @@ -112,6 +125,62 @@ Iterate over all pages of users for a search query
}
```

### Example B2B usage

Create an API client:
```go
import (
"context"

"github.com/stytchauth/stytch-go/v13/stytch"
"github.com/stytchauth/stytch-go/v13/stytch/b2b/b2bstytchapi"
"github.com/stytchauth/stytch-go/v13/stytch/b2b/organizations"
)

stytchClient, err := b2bstytchapi.NewClient(
"project-test-uuid",
"secret-test-uuid",
)
if err != nil {
panic(err)
}
```

Create an organization

```go
params := &organizations.CreateParams{
OrganizationName: "Example Org Inc.",
OrganizationSlug: "example-org",
}

resp, err := client.Organizations.Create(context.Background(), params)
if err != nil {
log.Fatalf("error in method call: %v", err)
}
```

Log the first user into the organization

```go
import (
"context"
"log"

"github.com/stytchauth/stytch-go/v13/stytch/b2b/b2bstytchapi"
"github.com/stytchauth/stytch-go/v13/stytch/b2b/magiclinks/email"
)
params := &email.LoginOrSignupParams{
OrganizationID: "organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931",
EmailAddress: "sandbox@stytch.com",
}

resp, err := client.MagicLinks.Email.LoginOrSignup(context.Background(), params)
if err != nil {
log.Fatalf("error in method call: %v", err)
}
```

## Handling Errors

When possible Stytch returns an error prepended with `Stytch Error`.
Expand Down

0 comments on commit 86b6fcd

Please sign in to comment.