Documentation ¶
Index ¶
Constants ¶
const ( // AuthURL is the URL to Webex Accounts Service's OAuth2 endpoint. AuthURL = "https://webexapis.com/v1/authorize" // TokenURL is the URL to the Webex Accounts Service's OAuth2 // token endpoint. TokenURL = "https://webexapis.com/v1/access_token" )
Variables ¶
var ErrMissingCredentials = errors.New("empty client id or secret")
ErrMissingCredentials if client id or secret are missing
Functions ¶
This section is empty.
Types ¶
type Webex ¶
type Webex struct { Client *http.Client // used for making request to webex ClientID string // Webex App Integration ClientID ClientSecret string // Webex App Integration Client Secret RedirectPort string // port on localhost to listen for webex response, as configured in the app integration redirectURI as http://localhost:PORT Scopes []string // scopes configured on Webex App Integration }
Webex is a top level struct for our communication with Webex
func (*Webex) GetAccessToken ¶
func (wbx *Webex) GetAccessToken(timeout int) (*WebexAccessTokenResponse, error)
GetAccessToken retrieves an integration token from Webex. It starts a server on localhost at the port specified, sends the user off for authentication and then retrieves an WebexAccessTokenResponse with the returned code from the authorization code grant for later use. Default listener is http://localhost:6855.
type WebexAccessTokenResponse ¶
type WebexAccessTokenResponse struct { AccessToken string `json:"access_token"` ExpiresIn int64 `json:"expires_in"` RefreshToken string `json:"refresh_token"` RefreshTokenExpiresIn int64 `json:"refresh_token_expires_in"` Message string Errors []struct { Description string `json:"description"` } `json:"errors"` TrackingID string `json:"trackingId"` }
WebexAccessTokenResponse is the response from Webex on requesting an access token using authorization code grant
func RefreshToken ¶
func RefreshToken(clientID, secret, refreshToken string) (*WebexAccessTokenResponse, error)
RefreshToken refreshes an existing token given the appropriate details.
func (WebexAccessTokenResponse) Expires ¶
func (t WebexAccessTokenResponse) Expires() string
Expires returns a string representation of when the token actually expires. Bear in mind that it is based off the ExpiresIn parameter which is relative to when you received the token.
func (WebexAccessTokenResponse) Save ¶
func (t WebexAccessTokenResponse) Save() error
Save saves the token details to the config file
func (WebexAccessTokenResponse) String ¶
func (t WebexAccessTokenResponse) String() string