1
1
# OAuth 2.1 Password Grant Type in Golang
2
- ![ workflow] ( https://github.com/syniol/golang-oauth-password-grant /actions/workflows/makefile.yml/badge.svg )
2
+ ![ workflow] ( https://github.com/syniol/golang-oauth2 /actions/workflows/makefile.yml/badge.svg )
3
3
4
- Implementation of standard OAuth 2.1 for Password Grant type in Golang
5
- and its native HTTP server.
4
+ Implementation of standard OAuth 2.1 for Password Grant type in Golang and its native HTTP server.
5
+
6
+
7
+ ## Healthcheck API
8
+ ``` text
9
+ GET oauth2/healthz HTTP/1.1
10
+ Host: 127.0.0.1
11
+ Content-Type: text/plain
12
+ ```
13
+
14
+ __ Request:__
15
+ ``` bash
16
+ curl -k --location --request GET ' https://127.0.0.1/healthz'
17
+ ```
18
+
19
+ __ Response:__
20
+ Status code ` 200 ` (OK) and a simple body response ` ok ` indicates API is working and operational.
21
+ ``` text
22
+ ok
23
+ ```
6
24
7
25
8
26
## Clients API
27
+ This endpoint is responsible for creating a new client/user to be inserted in database.
28
+
9
29
``` text
10
30
POST oauth2/clients HTTP/1.1
11
31
Host: 127.0.0.1
@@ -17,7 +37,7 @@ __Request:__
17
37
curl -k --location --request POST ' https://127.0.0.1/oauth2/clients' \
18
38
--header ' Content-Type: application/json' \
19
39
--data-raw ' {
20
- "username": "johndoe2 ",
40
+ "username": "johndoe ",
21
41
"password": "johnspassword1"
22
42
}'
23
43
```
@@ -31,6 +51,8 @@ __Response:__
31
51
32
52
33
53
## Token API
54
+ After client registration you can create a token sending a ` POST ` request to this endpoint.
55
+
34
56
``` text
35
57
POST oauth2/token HTTP/1.1
36
58
Host: 127.0.0.1
@@ -42,7 +64,7 @@ __Request:__
42
64
curl -k --location --request POST ' https://127.0.0.1/oauth2/token' \
43
65
--header ' Content-Type: application/x-www-form-urlencoded' \
44
66
--data-urlencode ' grant_type=password' \
45
- --data-urlencode ' username=johndoe1 ' \
67
+ --data-urlencode ' username=johndoe ' \
46
68
--data-urlencode ' password=johnspassword1'
47
69
```
48
70
0 commit comments