Skip to content

GitHub OAuth Example in Go#224

Merged
jonico merged 6 commits intomasterfrom
basic-auth-in-golang
Jun 28, 2019
Merged

GitHub OAuth Example in Go#224
jonico merged 6 commits intomasterfrom
basic-auth-in-golang

Conversation

@jonico
Copy link
Contributor

@jonico jonico commented Jan 8, 2019

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.

This is the sample project built by following the "[Basics of 
Authentication][basics of auth]"
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](https://github.com/github/platform-samples/blob/master/api/ruby/basics-of-authentication/server.rb) 
was ported. The example also shows how to use the [GitHub golang 
SDK](https://github.com/google/go-github).
@jonico jonico requested a review from UncannyBingo January 11, 2019 10:24
@jonico
Copy link
Contributor Author

jonico commented May 6, 2019

@larsxschneider: friendly bump 😊

@UncannyBingo
Copy link

I'm afraid I don't have the bandwidth to review this at the moment 🙁

@jonico jonico merged commit 3d40612 into master Jun 28, 2019
@jonico jonico deleted the basic-auth-in-golang branch June 28, 2019 06:14
@lowed132
Copy link

lowed132 commented Oct 6, 2019

Got some hacking into me on this I.p address 2a01:4c8:42d:37d9:1:2:a748:be2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants