Documentation ¶
Index ¶
- Variables
- func AuthorizationURL(input *AuthorizationURLInput) (*url.URL, error)
- func Validator() *validator.Validate
- type AccessToken
- type AccessTokenFromCallbackInput
- type AuthorizationURLInput
- type CurrentPerson
- type Failable
- type FakeConfig
- type FakeConfigOutput
- type FetchCurrentPersonInput
- type PerformInput
- type PerformOutput
- type PerformRefreshInput
Constants ¶
This section is empty.
Variables ¶
var ( // HTTPClient is an overrideable HTTP client for sending requests HTTPClient = &http.Client{Timeout: 5 * time.Second} // PlanningCenterScheme is the overrideable HTTP scheme for URLs generated PlanningCenterScheme = "https" // PlanningCenterHost is the overrideable HTTP host for URLs generated PlanningCenterHost = "api.planningcenteronline.com" )
Functions ¶
func AuthorizationURL ¶
func AuthorizationURL(input *AuthorizationURLInput) (*url.URL, error)
AuthorizationURL returns the URL to open in a web browser to start authorization
Types ¶
type AccessToken ¶
type AccessToken struct { Token string Kind string ExpiresIn int64 Refresh string Scope string CreatedAt int64 }
AccessToken is the Oauth access token used for authorization of requests
func AccessTokenFromCallback ¶
func AccessTokenFromCallback(input *AccessTokenFromCallbackInput) (*AccessToken, error)
AccessTokenFromCallback returns a new access token using the callback URL
func (*AccessToken) PerformRefresh ¶
func (a *AccessToken) PerformRefresh(input *PerformRefreshInput) (*AccessToken, error)
PerformRefresh refreshes the access token and returns a new one.
func (*AccessToken) SignRequest ¶
func (a *AccessToken) SignRequest(req *http.Request)
SignRequest adds the appropriate Authorization header to the request.
type AccessTokenFromCallbackInput ¶
type AccessTokenFromCallbackInput struct { CallbackURL *url.URL `validate:"required"` ClientID string `validate:"required"` ClientSecret string `validate:"required"` RedirectURL *url.URL `validate:"required"` // contains filtered or unexported fields }
AccessTokenFromCallbackInput is the required parameters for a call to AccessTokenFromCallback
type AuthorizationURLInput ¶
type AuthorizationURLInput struct { ClientID string `validate:"required,client_token"` CallbackURI *url.URL `validate:"required"` Scopes []string `validate:"min=1"` }
AuthorizationURLInput contains the required parameters for building the authorization URL
type CurrentPerson ¶
type CurrentPerson struct { // The authenticated person's organization ID OrganizationID string // The authenticated person's ID PersonID string }
CurrentPerson represents the authenticated person
func FetchCurrentPerson ¶
func FetchCurrentPerson(input *FetchCurrentPersonInput) (*CurrentPerson, error)
FetchCurrentPerson performs a GET to the Planning Center API to get the current person information.
type Failable ¶
type Failable interface {
Fail(err error)
}
Failable is a context type that can fail with an error.
type FakeConfig ¶
FakeConfig is the configuration of the fake server
type FakeConfigOutput ¶
FakeConfigOutput contains the values needed to perform successful requests to the fake server
func SetupForTesting ¶
func SetupForTesting(config *FakeConfig) FakeConfigOutput
SetupForTesting performs the setup for pco-auth to stub all requests to Planning Center and return fake data.
You don't haven't to do anything with the returned URL but it's there if you want to use this as a fake server for something else
type FetchCurrentPersonInput ¶
type FetchCurrentPersonInput struct { AccessToken *AccessToken `validate:"required"` // contains filtered or unexported fields }
FetchCurrentPersonInput contains the required parameters for a call to FetchCurrentPerson
type PerformInput ¶
type PerformInput struct { // The Oauth client id from api.planningcenteronline.com ClientID string `validate:"required,client_token"` // The Oauth client secret from api.planningcenteronline.com ClientSecret string `validate:"required,client_token"` // The scopes to authenticate with Scopes []string `validate:"required,min=1"` // The HTTP port to start listening on Port int `validate:"required"` // An optional place where progress data will be written to. Logger *log.Logger // Should the ID fetch be skipped? If true the output will be empty strings. SkipID bool }
PerformInput is the required values for the input of Perform
type PerformOutput ¶
type PerformOutput struct { // The access token that was just authenticated. AccessToken *AccessToken // The current person's organization id and person id CurrentPerson *CurrentPerson `json:",omitempty"` }
PerformOutput is the output of the Perform function call.
func Perform ¶
func Perform(input *PerformInput) (*PerformOutput, error)
Perform will perform the authorization for Planning Center Oauth
func PerformWithContext ¶
func PerformWithContext(ctx context.Context, input *PerformInput) (*PerformOutput, error)
PerformWithContext performs the authorization for Planning Center Oauth with the passed context
type PerformRefreshInput ¶
type PerformRefreshInput struct { // The Oauth client id from api.planningcenteronline.com ClientID string `validate:"required,client_token"` // The Oauth client secret from api.planningcenteronline.com ClientSecret string `validate:"required,client_token"` // contains filtered or unexported fields }
PerformRefreshInput contains the required information from the refresh token