# README
OAuth2 for Go
oauth2 package contains a client implementation for OAuth 2.0 spec.
See pkg.go.dev for further documentation and examples.
Policy for new endpoints
We no longer accept new provider-specific packages in this repo if all they do is add a single endpoint variable. If you just want to add a single endpoint, add it to the pkg.go.dev/golang.org/x/oauth2/endpoints package.
Report Issues / Send Patches
The main issue tracker for the oauth2 repository is located at https://github.com/golang/oauth2/issues.
This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://go.dev/doc/contribute.
The git repository is https://go.googlesource.com/oauth2.
Note:
- Excluding trivial changes, all contributions should be connected to an existing issue.
- API changes must go through the change proposal process before they can be accepted.
- The code owners are listed at dev.golang.org/owners.
# Packages
Package amazon provides constants for using OAuth2 to access Amazon.
Package authhandler implements a TokenSource to support "three-legged OAuth 2.0" via a custom AuthorizationHandler.
Package bitbucket provides constants for using OAuth2 to access Bitbucket.
Package cern provides constants for using OAuth2 to access CERN services.
Package clientcredentials implements the OAuth2.0 "client credentials" token flow, also known as the "two-legged OAuth 2.0".
Package endpoints provides constants for using OAuth2 to access various services.
Package facebook provides constants for using OAuth2 to access Facebook.
Package fitbit provides constants for using OAuth2 to access the Fitbit API.
Package foursquare provides constants for using OAuth2 to access Foursquare.
Package github provides constants for using OAuth2 to access Github.
Package gitlab provides constants for using OAuth2 to access GitLab.
Package google provides support for making OAuth2 authorized and authenticated HTTP requests to Google APIs.
Package heroku provides constants for using OAuth2 to access Heroku.
Package hipchat provides constants for using OAuth2 to access HipChat.
Package instagram provides constants for using OAuth2 to access Instagram.
Package jira provides claims and JWT signing for OAuth2 to access JIRA/Confluence.
Package jws provides a partial implementation of JSON Web Signature encoding and decoding.
Package jwt implements the OAuth 2.0 JSON Web Token flow, commonly known as "two-legged OAuth 2.0".
Package kakao provides constants for using OAuth2 to access Kakao.
Package linkedin provides constants for using OAuth2 to access LinkedIn.
Package mailchimp provides constants for using OAuth2 to access MailChimp.
Package mailru provides constants for using OAuth2 to access Mail.Ru.
Package mediamath provides constants for using OAuth2 to access MediaMath.
Package microsoft provides constants for using OAuth2 to access Windows Live ID.
Package nokiahealth provides constants for using OAuth2 to access the Nokia Health Mate API.
Package odnoklassniki provides constants for using OAuth2 to access Odnoklassniki.
Package paypal provides constants for using OAuth2 to access PayPal.
Package slack provides constants for using OAuth2 to access Slack.
Package spotify provides constants for using OAuth2 to access Spotify.
Package stackoverflow provides constants for using OAuth2 to access Stack Overflow.
Package twitch provides constants for using OAuth2 to access Twitch.
Package uber provides constants for using OAuth2 to access Uber.
Package vk provides constants for using OAuth2 to access VK.com.
Package yahoo provides constants for using OAuth2 to access Yahoo.
Package yandex provides constants for using OAuth2 to access Yandex APIs.
# Functions
GenerateVerifier generates a PKCE code verifier with 32 octets of randomness.
NewClient creates an *http.Client from a Context and TokenSource.
RegisterBrokenAuthHeaderProvider previously did something.
ReuseTokenSource returns a TokenSource which repeatedly returns the same token as long as it's valid, starting with t.
ReuseTokenSourceWithExpiry returns a TokenSource that acts in the same manner as the TokenSource returned by ReuseTokenSource, except the expiry buffer is configurable.
S256ChallengeFromVerifier returns a PKCE code challenge derived from verifier with method S256.
S256ChallengeOption derives a PKCE code challenge derived from verifier with method S256.
SetAuthURLParam builds an AuthCodeOption which passes key/value parameters to a provider's authorization endpoint.
StaticTokenSource returns a TokenSource that always returns the same token.
VerifierOption returns a PKCE code verifier AuthCodeOption.
# Constants
AuthStyleAutoDetect means to auto-detect which authentication style the provider wants by trying both ways and caching the successful way for the future.
AuthStyleInHeader sends the client_id and client_password using HTTP Basic Authorization.
AuthStyleInParams sends the "client_id" and "client_secret" in the POST body as application/x-www-form-urlencoded parameters.
# Variables
No description provided by the author
AccessTypeOnline and AccessTypeOffline are options passed to the Options.AuthCodeURL method.
ApprovalForce forces the users to view the consent dialog and confirm the permissions request at the URL returned from AuthCodeURL, even if they've already done so.
HTTPClient is the context key to use with golang.org/x/net/context's WithValue function to associate an *http.Client value with a context.
NoContext is the default context you should supply if not using your own context.Context (see https://golang.org/x/net/context).
# Structs
Config describes a typical 3-legged OAuth2 flow, with both the client application information and the server's endpoint URLs.
DeviceAuthResponse describes a successful RFC 8628 Device Authorization Response https://datatracker.ietf.org/doc/html/rfc8628#section-3.2.
Endpoint represents an OAuth 2.0 provider's authorization and token endpoint URLs.
RetrieveError is the error returned when the token endpoint returns a non-2XX HTTP status code or populates RFC 6749's 'error' parameter.
Token represents the credentials used to authorize the requests to access protected resources on the OAuth 2.0 provider's backend.
Transport is an http.RoundTripper that makes OAuth 2.0 HTTP requests, wrapping a base RoundTripper and adding an Authorization header with a token from the supplied Sources.
# Interfaces
An AuthCodeOption is passed to Config.AuthCodeURL.
A TokenSource is anything that can return a token.
# Type aliases
AuthStyle represents how requests for tokens are authenticated to the server.