basics-of-authentication

command
v0.0.0-...-2b2a6c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2024 License: CC0-1.0 Imports: 10 Imported by: 0

README

basics-of-authentication

This is the sample project built by following the "Basics of Authentication" guide on developer.github.com - ported to Go.

As the Go standard library does not come with built-in web session handling, only the simple example was ported. The example also shows how to use the GitHub golang SDK.

Install and Run project

First, of all, you would need to follow the steps in the GitHub OAuth Developer Guide to register an OAuth application with callback URL http://localhost:4567/callback.

Copy the client id and the secret of your newly created app and set them as environmental variables:

export GH_BASIC_SECRET_ID=<application secret>

export GH_BASIC_CLIENT_ID=<client id>

Make sure you have Go installed; then retrieve the modules needed for the go-github client library by running

go get github.com/google/go-github/github and

go get golang.org/x/oauth2 on the command line.

Finally, type go run server.go on the command line.

This command will run the server at localhost:4567. Visit http://localhost:4567 with your browser to get your GitHub email addresses revealed (after authorizing the GitHub OAuth App).

If you should get any errors while redirecting to GitHub, double check your environmental variables and the callback URL you set while registering your OAuth app.

Documentation

Overview

Simple OAuth server retrieving the email adresses of a GitHub user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL