osincli: github.com/RangelReale/osincli Index | Files

package osincli

import "github.com/RangelReale/osincli"

Index

Package Files

access.go authorize.go client.go config.go custom.go error.go pkce.go response.go util.go

Constants

const (
    E_INVALID_REQUEST           string = "invalid_request"
    E_UNAUTHORIZED_CLIENT              = "unauthorized_client"
    E_ACCESS_DENIED                    = "access_denied"
    E_UNSUPPORTED_RESPONSE_TYPE        = "unsupported_response_type"
    E_INVALID_SCOPE                    = "invalid_scope"
    E_SERVER_ERROR                     = "server_error"
    E_TEMPORARILY_UNAVAILABLE          = "temporarily_unavailable"
    E_UNSUPPORTED_GRANT_TYPE           = "unsupported_grant_type"
    E_INVALID_GRANT                    = "invalid_grant"
    E_INVALID_CLIENT                   = "invalid_client"
)

func GeneratePKCE Uses

func GeneratePKCE() (string, string, string, error)

func PopulatePKCE Uses

func PopulatePKCE(c *ClientConfig) error

type AccessData Uses

type AccessData struct {
    TokenType    string
    AccessToken  string
    RefreshToken string
    Expiration   *int32
    ResponseData ResponseData
}

Access data

type AccessRequest Uses

type AccessRequest struct {
    Type             AccessRequestType
    AuthorizeData    *AuthorizeData
    CustomParameters map[string]string
    // contains filtered or unexported fields
}

Access request information

func (*AccessRequest) GetToken Uses

func (c *AccessRequest) GetToken() (*AccessData, error)

Send a token request and capture data. On OAuth2 error, and osincli.Error is returned as error

func (*AccessRequest) GetTokenUrl Uses

func (c *AccessRequest) GetTokenUrl() *url.URL

Generate a token url. This may not be the exact url that is used, as it may be submited with basic authentication or form-encoded.

type AccessRequestType Uses

type AccessRequestType string
const (
    AUTHORIZATION_CODE AccessRequestType = "authorization_code"
    REFRESH_TOKEN                        = "refresh_token"
    PASSWORD                             = "password"
    CLIENT_CREDENTIALS                   = "client_credentials"
    IMPLICIT                             = "__implicit"
)

type AuthorizeData Uses

type AuthorizeData struct {
    Code  string
    State string

    // Resource Owner Password Credentials
    Username string
    Password string
}

Authorization data

type AuthorizeRequest Uses

type AuthorizeRequest struct {
    Type             AuthorizeRequestType
    CustomParameters map[string]string
    // contains filtered or unexported fields
}

Authorize request information

func (*AuthorizeRequest) GetAuthorizeUrl Uses

func (c *AuthorizeRequest) GetAuthorizeUrl() *url.URL

Returns the authorize url

func (*AuthorizeRequest) GetAuthorizeUrlWithParams Uses

func (c *AuthorizeRequest) GetAuthorizeUrlWithParams(state string) *url.URL

Returns the authorize url

func (*AuthorizeRequest) HandleRequest Uses

func (c *AuthorizeRequest) HandleRequest(r *http.Request) (*AuthorizeData, error)

Handle the authorization request

type AuthorizeRequestType Uses

type AuthorizeRequestType string
const (
    CODE AuthorizeRequestType = "code"
)

type BasicAuth Uses

type BasicAuth struct {
    Username string
    Password string
}

Parse basic authentication header

type Client Uses

type Client struct {

    // Transport is the HTTP transport to use when making requests.
    // It will default to http.DefaultTransport if nil.
    Transport http.RoundTripper
    // contains filtered or unexported fields
}

func NewClient Uses

func NewClient(config *ClientConfig) (*Client, error)

Creates a new client

func (*Client) NewAccessRequest Uses

func (c *Client) NewAccessRequest(t AccessRequestType, ad *AuthorizeData) *AccessRequest

func (*Client) NewAuthorizeRequest Uses

func (c *Client) NewAuthorizeRequest(t AuthorizeRequestType) *AuthorizeRequest

Creates a new authorize request

func (*Client) NewCustomRequest Uses

func (c *Client) NewCustomRequest() *CustomRequest

type ClientConfig Uses

type ClientConfig struct {
    ClientId                 string
    ClientSecret             string
    AuthorizeUrl             string
    TokenUrl                 string
    RedirectUrl              string
    Scope                    string
    ErrorsInStatusCode       bool
    SendClientSecretInParams bool
    UseGetAccessRequest      bool

    // PKCE / RFC7636 fields
    CodeChallenge       string
    CodeChallengeMethod string
    CodeVerifier        string
}

type CustomData Uses

type CustomData struct {
    ResponseData ResponseData
}

Custom data

type CustomRequest Uses

type CustomRequest struct {
    CustomParameters map[string]string
    // contains filtered or unexported fields
}

Custom request information

func (*CustomRequest) GetRequest Uses

func (c *CustomRequest) GetRequest(url *url.URL) (*CustomData, error)

Send a custom request On OAuth2 error, and osincli.Error is returned as error

type Error Uses

type Error struct {
    Id          string
    Description string
    URI         string
    State       string
}

OAuth2 error base

func NewError Uses

func NewError(id, description, uri, state string) *Error

func (*Error) Error Uses

func (e *Error) Error() string

type ResponseData Uses

type ResponseData map[string]interface{}

Data for response output

Package osincli imports 12 packages (graph) and is imported by 84 packages. Updated 2016-10-03. Refresh now. Tools for package owners.