Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteCredentials ¶
func SaveCredentials ¶
func SaveCredentials(profile string, pc *ProfileCredentials) error
Types ¶
type AuthTransport ¶
type AuthTransport struct {
Credentials *ProfileCredentials
Profile string
Base http.RoundTripper
// RefreshFunc is called to refresh expired tokens. Defaults to RefreshAccessToken.
RefreshFunc RefreshFunc
// contains filtered or unexported fields
}
type Credentials ¶
type Credentials struct {
Profiles map[string]ProfileCredentials `json:"profiles"`
}
type OAuthResult ¶ added in v0.4.15
OAuthResult holds the tokens returned by an OAuth flow or token refresh.
func OAuthFlow ¶
func OAuthFlow(subdomain, clientID, clientSecret, scope string) (*OAuthResult, error)
func RefreshAccessToken ¶ added in v0.4.15
func RefreshAccessToken(subdomain, clientID, refreshToken string) (*OAuthResult, error)
RefreshAccessToken exchanges a refresh token for a new access token. Zendesk refresh tokens are single-use: the response includes a new refresh token that must be stored to replace the old one.
type ProfileCredentials ¶
type ProfileCredentials struct {
Method string `json:"method"`
Subdomain string `json:"subdomain"`
Email string `json:"email,omitempty"`
APIToken string `json:"api_token,omitempty"`
OAuthToken string `json:"oauth_token,omitempty"`
OAuthClientID string `json:"oauth_client_id,omitempty"`
RefreshToken string `json:"refresh_token,omitempty"`
TokenExpiresAt *time.Time `json:"token_expires_at,omitempty"`
}
func LoadCredentials ¶
func LoadCredentials(profile string) (*ProfileCredentials, error)
func ResolveCredentials ¶
func ResolveCredentials(profile string) (*ProfileCredentials, error)
func (*ProfileCredentials) IsTokenExpired ¶ added in v0.4.15
func (pc *ProfileCredentials) IsTokenExpired() bool
IsTokenExpired returns true if the OAuth token is within 60 seconds of expiry. Returns false if no expiry is set (backward compat with legacy tokens).
type RefreshFunc ¶ added in v0.4.15
type RefreshFunc func(subdomain, clientID, refreshToken string) (*OAuthResult, error)
RefreshFunc is the signature for a function that refreshes an OAuth token.
Click to show internal directories.
Click to hide internal directories.