An example Go application demonstrating how to use the WorkOS Go SDK to authenticate users via SSO.
- Go
-
In your CLI, navigate to the directory into which you want to clone this git repo.
$ cd ~/Desktop/
-
Clone this git repo using your preferred secure method (HTTPS or SSH).
# HTTPS $ git clone https://github.com/workos-inc/go-sso-example.git
or
# SSH $ git clone git@github.com:workos-inc/go-sso-example.git
-
Navigate to the cloned repo.
$ cd go-sso-example
-
Obtain and make note of the following values. In the next step, these will be set as environment variables.
- Your WorkOS API key
- Your SSO-specific, WorkOS Project ID
- Your Redirect URI
-
Create a new file called ".env" in the root of the project and add the following variables, replacing the xxx with the values from step 4:
- WORKOS_API_KEY=xxx
- WORKOS_CLIENT_ID=xxx
- WORKOS_REDIRECT_URI=xxx
- WORKOS_DOMAIN=xxx
-
The final setup step is to start the server.
$ go run .
Navigate to
localhost:3042
in your web browser. You should see a "Login" button. If you click this link, you'll be redirected to an HTTP404
page because we haven't set up SSO yet!You can stop the local server for now by entering
CTRL + c
on the command line.
Follow the SSO authentication flow instructions to set up an SSO connection.
When you get to the step where you provide the REDIRECT_URI
value, use http://localhost:3042/callback.
If you get stuck, please reach out to us at support@workos.com so we can help.
-
Naviagte to the
go-sso-example
directory.$ go run .
Once running, navigate to http://localhost:3042 to test out the SSO workflow.
Hooray!
If you get stuck and aren't able to resolve the issue by reading our API reference or tutorials, you can reach out to us at support@workos.com and we'll lend a hand.