Home

Awesome

go.oauth2

loc license discord goreportcard codefactor

HTTP function handlers to easily add OAuth2 client support to your Go application

AppConf Schema

type AppConf struct {
	For    string `json:"for"`
	ID     string `json:"id"`
	Secret string `json:"secret"`
	Extra1 string `json:"extra_1"`
	Extra2 string `json:"extra_2"`
	Extra3 string `json:"extra_3"`
}

Creating Credentials

In order to use an app that uses this library, you will need to create an app on your Identity Provider of choice. Below, you will see a table of the supported Identity Providers and a link to the respective dashboards where you can go to create your app and obtain your App ID and App Secret.

Identity ProviderShort CodeDeveloper Dashboard
Amazonamazonhttps://developer.amazon.com/settings/console/securityprofile/overview.html
Battle.netbattle.nethttps://develop.battle.net/access/clients
Discorddiscordhttps://discordapp.com/developers/applications/
Facebookfacebookhttps://developers.facebook.com/apps/
GitHubgithubhttps://github.com/settings/developers
GitLabgitlab.comhttps://gitlab.com/profile/applications
Googlegooglehttps://console.developers.google.com
Microsoftmicrosofthttps://apps.dev.microsoft.com/
Redditreddithttps://www.reddit.com/prefs/apps

Installing

$ go get -v github.com/nektro/go.oauth2

Provider Schema

type Provider struct {
	ID           string `json:"id"`
	AuthorizeURL string `json:"authorize_url"`
	TokenURL     string `json:"token_url"`
	MeURL        string `json:"me_url"`
	Scope        string `json:"scope"`
	NameProp     string `json:"name_prop"`
	NamePrefix   string `json:"name_prefix"`
	Logo         string `json:"logo"`
	Color        string `json:"color"`
	Customable   string `json:"customable"`
}

AppConf Details for Self-Hosted Services

There are also a number of providers that allow you to specify a custom domain for that provider. They are accessed as such:

...
"clients": [
	{
		"for": "{provider_id},{domain}",
		"id": "",
		"secret": ""
	}
],
...

So for example, if adding a login config for https://mastodon.social/, your "for" key would be "mastodon,mastodon.social"

The full list of customizable provider are as follows:

Identity ProviderShort CodeHome Site
Giteagiteahttps://gitea.io/en-us/
Gitlabgitlabhttps://about.gitlab.com/
mastodonmastodonhttps://joinmastodon.org/
pleromapleromahttps://pleroma.social/

License

MIT