Skip to content

Commit f0c91c1

Browse files
authored
Merge pull request #35 from kinde-oss/ev/improving_docs
Enhance README.md with Go import examples and clarify usage
2 parents 6ebe395 + 4b5df74 commit f0c91c1

4 files changed

Lines changed: 44 additions & 8 deletions

File tree

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ The Kinde SDK for Go.
1010

1111
Requires Go 1.24+
1212

13-
### Usage
13+
## OAuth 2.0 Flows
1414

15-
```bash
16-
go get github.com/kinde-oss/kinde-go
17-
go mod tidy
18-
```
15+
For comprehensive information about OAuth 2.0 flows and how to choose the right flow for your application, see [OAuth 2.0 flows explained](https://kinde.com/learn/authentication/protocols/oauth-flows-explained/).
1916

2017
## Authorization Code Flow
2118

jwt/README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
The `jwt` package provides comprehensive JWT (JSON Web Token) parsing, validation, and management capabilities for the Kinde Go SDK. This package is designed to work seamlessly with OAuth2 flows and provides flexible validation options.
44

5+
## Learn More About JWTs
6+
7+
To better understand JSON Web Tokens, their structure, security features, and use cases, check out our comprehensive guide:
8+
9+
**[A complete guide to JSON Web Tokens (JWTs)](https://kinde.com/learn/authentication/types-and-methods/json-web-tokens/)**
10+
11+
This guide covers:
12+
13+
- What JSON Web Tokens are and how they work
14+
- JWT structure (header, payload, signature)
15+
- Security considerations and best practices
16+
- Common use cases for authentication and authorization
17+
- JWT benefits compared to other token types
18+
519
## Features
620

721
- **Multiple Parsing Methods**: Parse JWT tokens from HTTP headers, strings, session storage, or OAuth2 tokens
@@ -10,10 +24,12 @@ The `jwt` package provides comprehensive JWT (JSON Web Token) parsing, validatio
1024
- **Comprehensive Token Access**: Easy access to token claims, subject, issuer, audience, and other standard JWT fields
1125
- **Error Handling**: Detailed validation error reporting
1226

13-
## Installation
27+
## Go Imports
1428

15-
```bash
16-
go get github.com/kinde-oss/kinde-go/jwt
29+
```go
30+
import (
31+
"github.com/kinde-oss/kinde-go/jwt" // required
32+
)
1733
```
1834

1935
## Quick Start
@@ -41,6 +57,10 @@ if token.IsValid() {
4157
}
4258
```
4359

60+
**Important**: All validation options (e.g., `WillValidateWithJWKSUrl`, `WillValidateAlgorithm`, `WillValidateAudience`) are applied **once during token parsing**, not every time the token is read. The validation results are cached in the token object, so subsequent calls to `GetSubject()`, `GetIssuer()`, `GetAudience()`, etc. do not re-validate the token.
61+
62+
**Note for OAuth2 Flows**: When using the JWT package with OAuth2 flows (authorization_code or client_credentials), tokens are **re-validated every time they are retrieved from the token source**. This ensures that tokens remain valid throughout their lifecycle and any validation errors are caught when tokens are refreshed or retrieved from session storage.
63+
4464
## Parsing Methods
4565

4666
### ParseFromString

oauth2/authorization_code/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ The `authorization_code` package provides OAuth2 authorization code flow impleme
66

77
The authorization code flow is a backend authorization flow that requires a client secret. It is designed to be used as a server-side auth flow and does not expose tokens to the browser. User sessions need to be managed by other means, for example via session cookies.
88

9+
## Go Imports
10+
11+
```go
12+
import (
13+
"github.com/kinde-oss/kinde-go/oauth2/authorization_code" // required
14+
"github.com/kinde-oss/kinde-go/jwt" // optional - for JWT token validation
15+
)
16+
```
17+
918
## Standard Authorization Code Flow
1019

1120
### Basic Usage

oauth2/client_credentials/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ The `client_credentials` package provides OAuth2 client credentials flow impleme
66

77
The client credentials flow is designed for machine-to-machine communication which doesn't involve human input. It requires a Kinde M2M application and is ideal for server-to-server authentication scenarios.
88

9+
## Go Imports
10+
11+
```go
12+
import (
13+
"github.com/kinde-oss/kinde-go/oauth2/client_credentials" // required
14+
"github.com/kinde-oss/kinde-go/oauth2/client_credentials/cli" // optional - for CLI session storage
15+
"github.com/kinde-oss/kinde-go/jwt" // optional - for JWT token validation
16+
)
17+
```
18+
919
## Basic Usage
1020

1121
```go

0 commit comments

Comments
 (0)