This example shows you how to use the Okta JWT verifier library to secure a Golang REST API built with Gin.
Before running this sample, you will need the following:
- Go 1.13 +
- The Okta CLI Tool
- An Okta Developer Account, create one using
okta register
, or configure an existing one withokta login
Grab and configure this project using okta start go-api
You can also clone this project from GitHub.
git clone https://github.com/okta-samples/okta-go-api-sample.git
cd okta-go-api-sample
Note: Don't EVER commit
.okta.env
into source control. Add it to the.gitignore
file.
go run main.go
Now, send requests to http://localhost:8080.
curl -X GET http://localhost:8080/api/hello
# or
curl -X GET -H 'Authorization: Bearer ${TOKEN}’ http://localhost:8080/api/whoami
You can find more Golang sample in this repository