github

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2015 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeaderTwoFactor is the HTTP header that github users for two factor
	// authentication.
	//
	// In a request, the value of this header should be the two factor auth
	// code. In a response, the presence of this header indicates that two
	// factor authentication is required for the user. See
	// http://goo.gl/h7al6K for more information.
	HeaderTwoFactor = "X-GitHub-OTP"
)

Variables

View Source
var (
	// DefaultURL is the default location for the GitHub API.
	DefaultURL = "https://api.github.com"
)

Functions

This section is empty.

Types

type Authorization

type Authorization struct {
	Token string `json:"token"`
}

Authorization represents a GitHub Authorization. See http://goo.gl/bs9I3o for more information.

type Authorizer

type Authorizer struct {
	// OAuth scopes that should be granted with the access token.
	Scopes []string

	// The oauth application client id.
	ClientID string

	// The oauth application client secret.
	ClientSecret string

	// If provided, it will ensure that the user is a member of this
	// organization.
	Organization string
	// contains filtered or unexported fields
}

Authorizer is an implementation of the authorization.Authorizer interface backed by GitHub's Non-Web Application Flow, which can be found at http://goo.gl/onpQKM.

func (*Authorizer) Authorize

func (a *Authorizer) Authorize(username, password, twofactor string) (*empire.User, error)

type Client

type Client struct {
	// The github api url. The zero value is https://api.github.com.
	URL string
	// contains filtered or unexported fields
}

Client is a github client.

func (*Client) CreateAuthorization

func (c *Client) CreateAuthorization(opts CreateAuthorizationOpts) (*Authorization, error)

CreateAuthorization creates a new GitHub authorization (or returns the existing authorization if present) for the GitHub OAuth application. See http://goo.gl/bs9I3o.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

func (*Client) GetUser

func (c *Client) GetUser(token string) (*User, error)

GetUser makes an authenticated request to /user and returns the User.

func (*Client) IsMember

func (c *Client) IsMember(organization, token string) (bool, error)

IsMember returns true of the authenticated user is a member of the organization.

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, v interface{}) (*http.Request, error)

type CreateAuthorizationOpts

type CreateAuthorizationOpts struct {
	Scopes       []string
	ClientID     string
	ClientSecret string
	Username     string
	Password     string
	TwoFactor    string
}

CreateAuthorizationOpts is a set of options used when creating a GitHub authorization.

type User

type User struct {
	Login string `json:"login"`
}

Jump to

Keyboard shortcuts

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