https://github.com/kauemurakami/oauth_go
Basic OAuth with go lang
https://github.com/kauemurakami/oauth_go
go golang jwt oauth
Last synced: about 2 months ago
JSON representation
Basic OAuth with go lang
- Host: GitHub
- URL: https://github.com/kauemurakami/oauth_go
- Owner: kauemurakami
- Created: 2025-02-26T17:57:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-26T23:54:39.000Z (over 1 year ago)
- Last Synced: 2025-02-27T00:34:24.407Z (over 1 year ago)
- Topics: go, golang, jwt, oauth
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### First project Oauth with go lang
- access_token expires in 1 minuto (to facility test of the refresh)
- refresh_token expires in 7 days
You can change this in `core/helpers/auth/create_token.go`
### Dependencies
go get github.com/jackc/pgx
go get github.com/jackc/pgx/v5/pgconn@v5.7.2
go get github.com/lib/pq
go get github.com/joho/godotenv
```env
DB_HOST=127.0.0.1 or localhost ...
DB_USER=
DB_PASS=
DB_NAME=
DB_PORT= postgres default 5432
API_PORT= 8000 3000 ...
DB_SSL=disable
DB_TZ=America/Sao_Paulo your timezone
SECRET_KEY=
REFRESH_SECRET_KEY=
```
go get github.com/gorilla/mux
go get github.com/google/uuid
go get github.com/badoux/checkmail
go get golang.org/x/crypto/bcrypt
go get github.com/dgrijalva/jwt-go
go get github.com/golang-migrate/migrate
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
### Create migration up and down
migrate create -ext sql -dir ./core/data/db/migrations
### Migrate up to db
migrate -database postgres://DB_USER:DB_PASS@DB_HOST:DB_PORT/DB_NAME?sslmode=disable -path ./core/data/db/migrations up
### Migrate down db
migrate -database postgres://DB_USER:DB_PASS@DB_HOST:DB_PORT/DB_NAME?sslmode=disable -path ./core/data/db/migrations down
### Run
`go run main.go`