Documentation
¶
Index ¶
- Constants
- Variables
- func BuildURL(serverURL, urlFragment string, addRestAPI bool, queryValues url.Values) string
- func BuildURLPartial(urlFragment string, addRestAPI bool, queryValues url.Values) string
- func NewClientPassword(app ApplicationCredentials, pwd PasswordCredentials) (*http.Client, error)
- func NewClientPasswordEnv() (*http.Client, error)
- func NewClientPasswordSimple(app ApplicationCredentials, user UserCredentials) (*http.Client, error)
- func NewEndpoint(hostnameOrBasePath string) oauth2.Endpoint
- func NewHttpClientEnvFlexStatic(envPrefix string) (*http.Client, 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 SetHostnameForURL(serverURLString string) error
- func UsernameExtensionPasswordToHash(username, extension, password string, salt []byte) string
- func UsernameExtensionPasswordToString(username, extension, password string) string
- type ApplicationConfigEnv
- type ApplicationCredentials
- type ClientUtil
- type PasswordCredentials
- type RcToken
- type RingCentralAccount
- type RingCentralContact
- type RingCentralExtensionInfo
- type UserCredentials
Constants ¶
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 ¶
View Source
var ( 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
var (
Hostname = "platform.devtest.ringcentral.com"
)
Functions ¶
func BuildURLPartial ¶ added in v0.3.0
func NewClientPassword ¶
func NewClientPassword(app ApplicationCredentials, pwd PasswordCredentials) (*http.Client, error)
NewClientPassword uses dedicated password grant handling.
func NewClientPasswordEnv ¶ added in v0.3.0
func NewClientPasswordSimple ¶
func NewClientPasswordSimple(app ApplicationCredentials, user UserCredentials) (*http.Client, error)
NewClientPasswordSimple uses OAuth2 package password grant handling.
func NewEndpoint ¶
func NewTokenPassword ¶
func NewTokenPassword(app ApplicationCredentials, pwd PasswordCredentials) (*oauth2.Token, error)
func PasswordCredentialsToHash ¶
func PasswordCredentialsToHash(pwdCreds PasswordCredentials, salt []byte) string
func RetrieveToken ¶
func SetHostnameForURL ¶ added in v0.1.0
Types ¶
type ApplicationConfigEnv ¶ added in v0.3.0
type ApplicationConfigEnv struct { ClientID string `env:"RINGCENTRAL_CLIENT_ID"` ClientSecret string `env:"RINGCENTRAL_CLIENT_SECRET"` ServerURL string `env:"RINGCENTRAL_SERVER_URL" envDefault:"https://platform.ringcentral.com"` AccessToken string `env:"RINGCENTRAL_ACCESS_TOKEN"` Username string `env:"RINGCENTRAL_USERNAME"` Extension string `env:"RINGCENTRAL_EXTENSION"` Password string `env:"RINGCENTRAL_PASSWORD"` }
ApplicationConfigEnv returns a struct designed to be used to read values from the environment.
func NewApplicationConfigEnv ¶ added in v0.3.0
func NewApplicationConfigEnv() (ApplicationConfigEnv, error)
NewApplicationConfigEnv returns a new ApplicationConfigEnv populated with values from the environment.
func (*ApplicationConfigEnv) ApplicationCredentials ¶ added in v0.3.0
func (cfg *ApplicationConfigEnv) ApplicationCredentials() ApplicationCredentials
ApplicationCredentials returns a ApplicationCredentials struct.
func (*ApplicationConfigEnv) LoadToken ¶ added in v0.3.0
func (cfg *ApplicationConfigEnv) LoadToken() (*oauth2.Token, error)
LoadToken loads and returns an OAuth token.
func (*ApplicationConfigEnv) PasswordCredentials ¶ added in v0.3.0
func (cfg *ApplicationConfigEnv) PasswordCredentials() PasswordCredentials
PasswordCredentials returns a PasswordCredentials struct.
type ApplicationCredentials ¶
type ApplicationCredentials struct { ServerURL string ApplicationID string ClientID string ClientSecret string RedirectURL string AppName string AppVersion string OAuthEndpointID string AccessTokenTTL int64 RefreshTokenTTL int64 }
func NewApplicationCredentialsEnv ¶
func NewApplicationCredentialsEnv() ApplicationCredentials
func (*ApplicationCredentials) AppNameAndVersion ¶
func (ac *ApplicationCredentials) AppNameAndVersion() string
func (*ApplicationCredentials) Config ¶
func (app *ApplicationCredentials) Config() oauth2.Config
type ClientUtil ¶
type ClientUtil struct { Client *http.Client `json:"-"` 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 (apiutil *ClientUtil) GetUserinfo() (RingCentralExtensionInfo, error)
GetUserinfo retrieves the userinfo from the https://graph.facebook.com/v2.9/{user-id} endpoint.
func (*ClientUtil) SetClient ¶
func (apiutil *ClientUtil) SetClient(client *http.Client)
type PasswordCredentials ¶
type PasswordCredentials struct { GrantType string `url:"grant_type"` AccessTokenTTL int64 `url:"access_token_ttl"` RefreshTokenTTL int64 `url:"refresh_token_ttl"` Username string `url:"username"` Extension string `url:"extension"` Password string `url:"password"` EndpointId string `url:"endpoint_id"` }
func NewPasswordCredentialsEnv ¶
func NewPasswordCredentialsEnv() PasswordCredentials
func (*PasswordCredentials) URLValues ¶
func (pw *PasswordCredentials) URLValues() url.Values
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"` }
type UserCredentials ¶ added in v0.1.0
func (*UserCredentials) UsernameSimple ¶ added in v0.3.0
func (uc *UserCredentials) UsernameSimple() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.