Skip to content

okta-samples/okta-go-api-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Okta Golang Gin Resource Server Example

This example shows you how to use the Okta JWT verifier library to secure a Golang REST API built with Gin.

Prerequisites

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 with okta login

Configure Okta

Ensure that your default custom authorization server has an access policy. Add an access policy if it's not there. See Create access polices.

Get the Code

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.

Run the Example

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

Releases

No releases published

Packages

No packages published

Languages