Documentation
¶
Index ¶
- Constants
- func BuildURL(serverURL, urlFragment string, addRestAPI bool, queryValues url.Values) (string, error)
- func NewClientPassword(app ApplicationCredentials, pwd PasswordCredentials) (*http.Client, error)
- func NewClientPasswordSimple(app ApplicationCredentials, user PasswordCredentials) (*http.Client, error)
- func NewEndpoint(hostnameOrBasePath string) oauth2.Endpoint
- func NewHttpClientEnvFlexStatic(envPrefix string) (*http.Client, error)
- func NewTokenCli(creds Credentials, state string) (token *oauth2.Token, err error)
- func NewTokenPassword(app ApplicationCredentials, pwd PasswordCredentials) (*oauth2.Token, error)
- func PasswordCredentialsToHash(pwdCreds PasswordCredentials, salt []byte) string
- func RetrieveToken(cfg oauth2.Config, params url.Values) (*oauth2.Token, error)
- func UsernameExtensionPasswordToHash(username, extension, password string, salt []byte) string
- func UsernameExtensionPasswordToString(username, extension, password string) string
- type ApplicationCredentials
- func (ac *ApplicationCredentials) AppNameAndVersion() string
- func (app *ApplicationCredentials) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string
- func (app *ApplicationCredentials) Config() oauth2.Config
- func (app *ApplicationCredentials) Exchange(code string) (*RcToken, error)
- func (app *ApplicationCredentials) InflateURL(apiUrlPath string) string
- func (app *ApplicationCredentials) IsGrantType(grantType string) bool
- type ClientUtil
- type Credentials
- func (creds *Credentials) Me() (RingCentralExtensionInfo, error)
- func (creds *Credentials) MeScim() (scim.User, error)
- func (creds *Credentials) NewClient() (*http.Client, error)
- func (creds *Credentials) NewClientCli(oauth2State string) (*http.Client, error)
- func (creds *Credentials) NewClientUtil() (ClientUtil, error)
- func (creds *Credentials) NewSimpleClient() (*httpsimple.SimpleClient, error)
- func (creds *Credentials) NewToken() (*oauth2.Token, error)
- func (creds *Credentials) NewTokenCli(oauth2State string) (*oauth2.Token, error)
- type CredentialsSet
- func (set *CredentialsSet) Accounts() []string
- func (set *CredentialsSet) Get(key string) (Credentials, error)
- func (set *CredentialsSet) GetClient(key string) (*http.Client, error)
- func (set *CredentialsSet) Keys() []string
- func (set *CredentialsSet) NewSimpleClient(key string) (*httpsimple.SimpleClient, error)
- type PasswordCredentials
- type RcToken
- type RingCentralAccount
- type RingCentralContact
- type RingCentralExtensionInfo
Constants ¶
View Source
const ( EnvServerURL = "RINGCENTRAL_SERVER_URL" EnvClientID = "RINGCENTRAL_CLIENT_ID" EnvClientSecret = "RINGCENTRAL_CLIENT_SECRET" EnvAppName = "RINGCENTRAL_APP_NAME" EnvAppVersion = "RINGCENTRAL_APP_VERSION" EnvRedirectURL = "RINGCENTRAL_OAUTH_REDIRECT_URL" EnvUsername = "RINGCENTRAL_USERNAME" EnvExtension = "RINGCENTRAL_EXTENSION" EnvPassword = "RINGCENTRAL_PASSWORD" )
View Source
const ( ServerURLProduction = "https://platform.ringcentral.com" ServerURLSandbox = "https://platform.devtest.ringcentral.com" ProductionHostname = "platform.ringcentral.com" SandboxHostname = "platform.devtest.ringcentral.com" AuthURLFormat = "https://%s/restapi/oauth/authorize" TokenURLFormat = "https://%s/restapi/oauth/token" AuthURLPart = "restapi/oauth/authorize" TokenURLPart = "restapi/oauth/token" MeURL = "/restapi/v1.0/account/~/extension/~" RestAPI1dot0Fragment = "restapi/v1.0" )
Variables ¶
This section is empty.
Functions ¶
func NewClientPassword ¶
func NewClientPassword(app ApplicationCredentials, pwd PasswordCredentials) (*http.Client, error)
NewClientPassword uses dedicated password grant handling.
func NewClientPasswordSimple ¶
func NewClientPasswordSimple(app ApplicationCredentials, user PasswordCredentials) (*http.Client, error)
NewClientPasswordSimple uses OAuth2 package password grant handling.
func NewEndpoint ¶
func NewTokenCli ¶ added in v0.4.1
func NewTokenCli(creds Credentials, state string) (token *oauth2.Token, err error)
func NewTokenPassword ¶
func NewTokenPassword(app ApplicationCredentials, pwd PasswordCredentials) (*oauth2.Token, error)
func PasswordCredentialsToHash ¶
func PasswordCredentialsToHash(pwdCreds PasswordCredentials, salt []byte) string
func RetrieveToken ¶
Types ¶
type ApplicationCredentials ¶
type ApplicationCredentials struct { ApplicationID string `json:"applicationID,omitempty"` ClientID string `json:"clientID,omitempty"` ClientSecret string `json:"clientSecret,omitempty"` RedirectURL string `json:"redirectURL,omitempty"` ServerURL string `json:"serverURL,omitempty"` AppName string `json:"applicationName,omitempty"` AppVersion string `json:"applicationVersion,omitempty"` OAuthEndpointID string `json:"oauthEndpointID,omitempty"` AccessTokenTTL int64 `json:"accessTokenTTL,omitempty"` RefreshTokenTTL int64 `json:"refreshTokenTTL,omitempty"` GrantType string `json:"grantType,omitempty"` }
func NewApplicationCredentialsEnv ¶
func NewApplicationCredentialsEnv() ApplicationCredentials
func (*ApplicationCredentials) AppNameAndVersion ¶
func (ac *ApplicationCredentials) AppNameAndVersion() string
func (*ApplicationCredentials) AuthCodeURL ¶ added in v0.4.1
func (app *ApplicationCredentials) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string
func (*ApplicationCredentials) Config ¶
func (app *ApplicationCredentials) Config() oauth2.Config
func (*ApplicationCredentials) Exchange ¶
func (app *ApplicationCredentials) Exchange(code string) (*RcToken, error)
func (*ApplicationCredentials) InflateURL ¶ added in v0.4.3
func (app *ApplicationCredentials) InflateURL(apiUrlPath string) string
func (*ApplicationCredentials) IsGrantType ¶ added in v0.4.1
func (app *ApplicationCredentials) IsGrantType(grantType string) bool
type ClientUtil ¶
type ClientUtil struct { Client *http.Client `json:"-"` ServerURL string User RingCentralExtensionInfo `json:"user,omitempty"` }
ClientUtil is a client library to retrieve user info from the Facebook API.
func NewClientUtil ¶
func NewClientUtil(client *http.Client) ClientUtil
func (*ClientUtil) GetSCIMUser ¶
func (apiutil *ClientUtil) GetSCIMUser() (scim.User, error)
func (*ClientUtil) GetUserinfo ¶
func (cu *ClientUtil) GetUserinfo() (RingCentralExtensionInfo, error)
GetUserinfo retrieves the userinfo from the https://graph.facebook.com/v2.9/{user-id} endpoint.
func (*ClientUtil) SetClient ¶
func (cu *ClientUtil) SetClient(client *http.Client)
type Credentials ¶
type Credentials struct { Application ApplicationCredentials `json:"application,omitempty"` PasswordCredentials PasswordCredentials `json:"passwordCredentials,omitempty"` Token *oauth2.Token `json:"token,omitempty"` }
func NewCredentialsEnv ¶
func NewCredentialsEnv() Credentials
func NewCredentialsJSON ¶
func NewCredentialsJSON(jsonData []byte) (Credentials, error)
func NewCredentialsJSONs ¶
func NewCredentialsJSONs(appJson, userJson, accessToken []byte) (Credentials, error)
func ReadCredentialsFromFile ¶
func ReadCredentialsFromFile(filename, key string) (Credentials, error)
func (*Credentials) Me ¶
func (creds *Credentials) Me() (RingCentralExtensionInfo, error)
func (*Credentials) NewClientCli ¶ added in v0.4.3
func (creds *Credentials) NewClientCli(oauth2State string) (*http.Client, error)
func (*Credentials) NewClientUtil ¶
func (creds *Credentials) NewClientUtil() (ClientUtil, error)
func (*Credentials) NewSimpleClient ¶ added in v0.4.3
func (creds *Credentials) NewSimpleClient() (*httpsimple.SimpleClient, error)
func (*Credentials) NewTokenCli ¶ added in v0.4.3
func (creds *Credentials) NewTokenCli(oauth2State string) (*oauth2.Token, error)
NewTokenCli retrieves a token using CLI approach for OAuth 2.0 authorization code or password grant.
type CredentialsSet ¶
type CredentialsSet struct {
Credentials map[string]Credentials
}
func ReadFileCredentialsSet ¶
func ReadFileCredentialsSet(filename string) (CredentialsSet, error)
func (*CredentialsSet) Accounts ¶ added in v0.4.3
func (set *CredentialsSet) Accounts() []string
func (*CredentialsSet) Get ¶
func (set *CredentialsSet) Get(key string) (Credentials, error)
func (*CredentialsSet) GetClient ¶
func (set *CredentialsSet) GetClient(key string) (*http.Client, error)
func (*CredentialsSet) Keys ¶ added in v0.4.3
func (set *CredentialsSet) Keys() []string
func (*CredentialsSet) NewSimpleClient ¶ added in v0.4.3
func (set *CredentialsSet) NewSimpleClient(key string) (*httpsimple.SimpleClient, error)
type PasswordCredentials ¶
type PasswordCredentials struct { GrantType string `url:"grant_type"` AccessTokenTTL int64 `url:"access_token_ttl"` RefreshTokenTTL int64 `url:"refresh_token_ttl"` Username string `json:"username" url:"username"` Extension string `json:"extension" url:"extension"` Password string `json:"password" url:"password"` EndpointId string `url:"endpoint_id"` EngageVoiceAccountId int64 `json:"engageVoiceAccountId"` }
func NewPasswordCredentialsEnv ¶
func NewPasswordCredentialsEnv() PasswordCredentials
func (*PasswordCredentials) URLValues ¶
func (pw *PasswordCredentials) URLValues() url.Values
func (*PasswordCredentials) UsernameSimple ¶
func (uc *PasswordCredentials) UsernameSimple() string
type RcToken ¶
type RcToken struct { AccessToken string `json:"access_token,omitempty"` TokenType string `json:"token_type,omitempty"` Scope string `json:"scope,omitempty"` ExpiresIn int64 `json:"expires_in,omitempty"` RefreshToken string `json:"refresh_token,omitempty"` RefreshTokenExpiresIn int64 `json:"refresh_token_expires_in,omitempty"` OwnerID string `json:"owner_id,omitempty"` EndpointID string `json:"endpoint_id,omitempty"` Expiry time.Time `json:"expiry,omitempty"` RefreshTokenExpiry time.Time `json:"refresh_token_expiry,omitempty"` // contains filtered or unexported fields }
type RingCentralAccount ¶
type RingCentralContact ¶
type RingCentralExtensionInfo ¶
type RingCentralExtensionInfo struct { ID int64 `json:"id,omitempty"` ExtensionNumber string `json:"extensionNumber,omitempty"` Contact RingCentralContact `json:"contact,omitempty"` Name string `json:"name,omitempty"` Account RingCentralAccount `json:"account,omitempty"` }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.