Skip to content

Commit 67ee4ff

Browse files
Fix Auth Docs (#375)
* add oauth docs * update docs * revert code cahnges * update docs * sort env * update docs * fix docs headings
1 parent 7e12888 commit 67ee4ff

File tree

2 files changed

+8
-7
lines changed
  • docs/advanced-guide/http-authentication
  • examples/http-server-using-redis/configs

2 files changed

+8
-7
lines changed

docs/advanced-guide/http-authentication/page.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ func main() {
119119
}
120120
```
121121

122-
### Adding Basic Authentication to HTTP Services
122+
### Adding API-KEY Authentication to HTTP Services
123123
This code snippet demonstrates how to add API Key authentication to an HTTP service in GoFr and make a request with the appropriate Authorization header:
124124

125125
```go
126-
app.AddHTTPService("http-server-using-redis", "http://localhost:8000", &service.APIKeyAuth{APIKey: "9221e451-451f-4cd6-a23d-2b2d3adea9cf"})
126+
app.AddHTTPService("http-server-using-redis", "http://localhost:8000", &service.APIKeyConfig{APIKey: "9221e451-451f-4cd6-a23d-2b2d3adea9cf"})
127127
```
128128

129129
## 3. OAuth 2.0
@@ -146,7 +146,7 @@ Use `EnableOAuth(jwks-endpoint,refresh_interval)` to configure Gofr with pre-def
146146
func main() {
147147
app := gofr.New()
148148

149-
app.EnableOAuth("http://jwks-endpoint", 20) // Replace with your credentials
149+
app.EnableOAuth("http://jwks-endpoint", 20)
150150

151151
app.GET("/protected-resource", func(c *gofr.Context) (interface{}, error) {
152152
// Handle protected resource access
@@ -157,7 +157,7 @@ func main() {
157157
}
158158
```
159159

160-
### Adding Basic Authentication to HTTP Services
160+
### Adding OAuth Authentication to HTTP Services
161161
For server-to-server communication it follows two-legged OAuth, also known as "client credentials" flow,
162162
where the client application directly exchanges its own credentials (ClientID and ClientSecret)
163163
for an access token without involving any end-user interaction.
@@ -166,7 +166,7 @@ This code snippet demonstrates how two-legged OAuth authentication is added to a
166166

167167
```go
168168
a.AddHTTPService("orders", "http://localhost:9000",
169-
&service.OAuthConfig{
169+
&service.OAuthConfig{ // Replace with your credentials
170170
ClientID: "0iyeGcLYWudLGqZfD6HvOdZHZ5TlciAJ",
171171
ClientSecret: "GQXTY2f9186nUS3C9WWi7eJz8-iVEsxq7lKxdjfhOJbsEPPtEszL3AxFn8k_NAER",
172172
TokenURL: "https://dev-zq6tvaxf3v7p0g7j.us.auth0.com/oauth/token",
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
APP_NAME=sample-api
22
HTTP_PORT=8000
33

4-
LOG_LEVEL=DEBUG
5-
64
REDIS_HOST=localhost
75
REDIS_PORT=2002
86

7+
LOG_LEVEL=DEBUG
8+
9+

0 commit comments

Comments
 (0)