package
0.1.0
Repository: https://github.com/yosmudge/graphatmo.git
Documentation: pkg.go.dev

# README

OAuth2 for Go

Build Status

oauth2 package contains a client implementation for OAuth 2.0 spec.

Installation

go get golang.org/x/oauth2

See godoc for further documentation and examples.

App Engine

In change 96e89be (March 2015) we removed the oauth2.Context2 type in favor of the context.Context type from the golang.org/x/net/context package

This means its no longer possible to use the "Classic App Engine" appengine.Context type with the oauth2 package. (You're using Classic App Engine if you import the package "appengine".)

To work around this, you may use the new "google.golang.org/appengine" package. This package has almost the same API as the "appengine" package, but it can be fetched with go get and used on "Managed VMs" and well as Classic App Engine.

See the new appengine package's readme for information on updating your app.

If you don't want to update your entire app to use the new App Engine packages, you may use both sets of packages in parallel, using only the new packages with the oauth2 package.

import (
	"golang.org/x/net/context"
	"golang.org/x/oauth2"
	"golang.org/x/oauth2/google"
	newappengine "google.golang.org/appengine"
	newurlfetch "google.golang.org/appengine/urlfetch"

	"appengine"
)

func handler(w http.ResponseWriter, r *http.Request) {
	var c appengine.Context = appengine.NewContext(r)
	c.Infof("Logging a message with the old package")

	var ctx context.Context = newappengine.NewContext(r)
	client := &http.Client{
		Transport: &oauth2.Transport{
			Source: google.AppEngineTokenSource(ctx, "scope"),
			Base:   &newurlfetch.Transport{Context: ctx},
		},
	}
	client.Get("...")
}

# Packages

Package bitbucket provides constants for using OAuth2 to access Bitbucket.
Package clientcredentials implements the OAuth2.0 "client credentials" token flow, also known as the "two-legged OAuth 2.0".
Package facebook provides constants for using OAuth2 to access Facebook.
Package github provides constants for using OAuth2 to access Github.
Package google provides support for making OAuth2 authorized and authenticated HTTP requests to Google APIs.
Package jws provides encoding and decoding utilities for signed JWS messages.
Package jwt implements the OAuth 2.0 JSON Web Token flow, commonly known as "two-legged OAuth 2.0".
Package linkedin provides constants for using OAuth2 to access LinkedIn.
Package odnoklassniki provides constants for using OAuth2 to access Odnoklassniki.
Package paypal provides constants for using OAuth2 to access PayPal.
Package vk provides constants for using OAuth2 to access VK.com.

# Functions

NewClient creates an *http.Client from a Context and TokenSource.
RegisterBrokenAuthHeaderProvider registers an OAuth2 server identified by the tokenURL prefix as an OAuth2 implementation which doesn't support the HTTP Basic authentication scheme to authenticate with the authorization server.
ReuseTokenSource returns a TokenSource which repeatedly returns the same token as long as it's valid, starting with t.
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.

# 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.
Endpoint contains the OAuth 2.0 provider's authorization and token endpoint URLs.
Token represents the crendentials 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.