Documentation ¶
Index ¶
- Constants
- func GenerateJWT(clientId string, serviceAccountId string, privateKey string) string
- func ListConfigProfiles() []string
- func StartCallbackServer(ctx context.Context, addr string, port string, path string, timeoutSec int16, ...)
- type AccessTokenJWTRequestBody
- type AccessTokenRequestBody
- type AccessTokenResponseBody
- type CallbackHandler
- type ClientCredential
- func (cred *ClientCredential) AuthCodeURL(state string) string
- func (cred *ClientCredential) GetAccessToken(code string) Token
- func (cred *ClientCredential) GetAccessTokenJWT(sva ServiceAccount) Token
- func (cred *ClientCredential) GetRedirectUrl() string
- func (cred ClientCredential) ReadConfig(profile string) (*ClientCredential, error)
- func (cred *ClientCredential) WriteConfig(profile string) error
- type RefreshTokenRequestBody
- type RefreshTokenResponseBody
- type ServiceAccount
- type Token
Constants ¶
View Source
const AuthURL = "https://auth.worksmobile.com/oauth2/v2.0/authorize"
View Source
const CONFIG_DIR_NAME = ".config"
View Source
const CONFIG_OAUTH_FILE_NAME = "oauth.toml"
View Source
const CONFIG_PATH_ENV_NAME = "LINEWORKS_CONFIG_DIR"
View Source
const CONFIG_SERVICE_ACCOUNT_FILE_NAME = "service_account.toml"
View Source
const CONFIG_SERVICE_DIR_NAME = "lineworks"
View Source
const CONFIG_TOKEN_FILE_NAME = "token.toml"
View Source
const TokenURL = "https://auth.worksmobile.com/oauth2/v2.0/token"
Variables ¶
This section is empty.
Functions ¶
func GenerateJWT ¶
Generate JWT
func ListConfigProfiles ¶
func ListConfigProfiles() []string
Types ¶
type AccessTokenRequestBody ¶
type AccessTokenResponseBody ¶
type AccessTokenResponseBody struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` Scopes string `json:"scope"` ExpiredIn string `json:"expires_in"` TokenType string `json:"token_type"` }
func RequestAccessToken ¶
func RequestAccessToken(req_body AccessTokenRequestBody) (AccessTokenResponseBody, error)
Get AccessToken
func RequestAccessTokenJWT ¶
func RequestAccessTokenJWT(req_body AccessTokenJWTRequestBody) (AccessTokenResponseBody, error)
Get AccessToken (JWT)
type CallbackHandler ¶
type CallbackHandler struct { Context context.Context ContextCancel context.CancelFunc CallbackFunc func(code string, state string) error }
func (*CallbackHandler) ServeHTTP ¶
func (handler *CallbackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ClientCredential ¶
type ClientCredential struct { ClientID string `toml:"client_id" json:"client_id"` ClientSecret string `toml:"client_secret" json:"client_secret"` Scopes string `toml:"scopes" json:"scopes"` ListenAddr string `toml:"addr" json:"addr"` ListenPort string `toml:"port" json:"port"` RedirectPath string `toml:"path" json:"path"` DomainID string `toml:"domain_id,omitempty" json:"domain_id,omitempty"` }
func (*ClientCredential) AuthCodeURL ¶
func (cred *ClientCredential) AuthCodeURL(state string) string
Generate Authorization Code URL
func (*ClientCredential) GetAccessToken ¶
func (cred *ClientCredential) GetAccessToken(code string) Token
Get access token
func (*ClientCredential) GetAccessTokenJWT ¶
func (cred *ClientCredential) GetAccessTokenJWT(sva ServiceAccount) Token
Get access token (JWT)
func (*ClientCredential) GetRedirectUrl ¶
func (cred *ClientCredential) GetRedirectUrl() string
Get Redirect URL
func (ClientCredential) ReadConfig ¶
func (cred ClientCredential) ReadConfig(profile string) (*ClientCredential, error)
func (*ClientCredential) WriteConfig ¶
func (cred *ClientCredential) WriteConfig(profile string) error
type RefreshTokenRequestBody ¶
type ServiceAccount ¶
type ServiceAccount struct { ServiceAccountID string `toml:"service_account_id" json:"service_account_id"` PrivateKey string `toml:"private_key" json:"private_key"` }
func (ServiceAccount) ReadConfig ¶
func (sa ServiceAccount) ReadConfig(profile string) (*ServiceAccount, error)
func (*ServiceAccount) WriteConfig ¶
func (sa *ServiceAccount) WriteConfig(profile string) error
Click to show internal directories.
Click to hide internal directories.