Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/khareyash05/jwt-go
https://github.com/khareyash05/jwt-go
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/khareyash05/jwt-go
- Owner: khareyash05
- Created: 2024-07-07T17:23:36.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-07-19T05:12:20.000Z (4 months ago)
- Last Synced: 2024-07-19T13:16:32.473Z (4 months ago)
- Language: Go
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JWT Go example
Example application based on my blog post on [Implementing JWT based authentication in Golang](https://www.sohamkamani.com/golang/jwt-authentication/)
To run this application, build and run the Go binary:
```sh
go build
./jwt-go-example
```Now, using any HTTP client with support for cookies (like [Postman](https://www.getpostman.com/apps), or your web browser) make a sign-in request with the appropriate credentials:
```
POST http://localhost:8000/signin{"username":"user1","password":"password1"}
```You can now try hitting the welcome route from the same client to get the welcome message:
```
GET http://localhost:8000/welcome
```Hit the refresh route, and then inspect the clients cookies to see the new value of the `token` cookie:
```
POST http://localhost:8000/refresh
```