Documentation
¶
Overview ¶
Package token manages the Access token.
Index ¶
Constants ¶
const ( SuffixSecond = "s" ErrMSGNotEnoughArgs = "At least one scope should be present" ErrMSGUnableToGetClientCreds = "Unable to get Client credentials" ErrMSGUnableToGetAccessToken = "Unable to get access token for scopes: %v" ErrMSGUnableToParseExpireTime = "Unable parse expiresIn time" ErrMsgUnableToParseRequestBody = "unable to parse request body: %s" ErrMsgUnableToCreateRequestBody = "unable to create request body: %s" GenerateAccessToken = "Generating access Token" DynamicClientRegMsg = "Dynamic Client Reg" RefreshTokenContext = "Refresh token" Context = "/token" UserName = "username" Password = "password" GrantPassword = "password" GrantRefreshToken = "refresh_token" GrantType = "grant_type" Scope = "scope" RefreshToken = "refresh_token" ScopeSubscribe = "apim:subscribe" ScopeAPIView = "apim:api_view" LogKeyAT = "access-token" LogKeyRT = "refresh-token" LogKeyExpiresIn = "expires in" // CallBackURL is a dummy value CallBackURL = "www.dummy.com" // ClientName for dynamic client registration ClientName = "apim_service_broker" // DynamicClientRegGrantType for dynamic client registration DynamicClientRegGrantType = "password refresh_token" // Owner for dynamic client registration Owner = "admin" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicCredentials ¶
BasicCredentials represents the username and Password.
type DynamicClientRegReq ¶
type DynamicClientRegReq struct { CallbackURL string `json:"callbackUrl"` ClientName string `json:"clientName"` Owner string `json:"owner"` GrantType string `json:"grantType"` SaasApp bool `json:"saasApp"` }
DynamicClientRegReq represents the request for Dynamic client request body.
type DynamicClientRegResBody ¶
type DynamicClientRegResBody struct { CallbackURL string `json:"callBackURL"` JSONString string `json:"jsonString"` ClientName string `json:"clientName"` ClientID string `json:"clientId"` ClientSecret string `json:"clientSecret"` IsSaasApplication bool `json:"isSaasApplication"` }
DynamicClientRegResBody represents the message body for Dynamic client registration response body.
type Manager ¶
type Manager interface { // Init initialize the Token Manager. Generate token for the given scopes. // Must run before using the Token Manager. Init(scopes []string) // Token method returns an access token and any error occurred. Token() (string, error) }
Manager interface manages the token for a set of given scopes.
type PasswordRefreshTokenGrantManager ¶
type PasswordRefreshTokenGrantManager struct { TokenEndpoint string DynamicClientEndpoint string DynamicClientRegistrationContext string UserName string Password string // contains filtered or unexported fields }
PasswordRefreshTokenGrantManager is used to manage Access token using password and refresh_token grant type. Holds access token for the given scopes and regenerate token using refresh token if the access token is expired.
func (*PasswordRefreshTokenGrantManager) Init ¶
func (m *PasswordRefreshTokenGrantManager) Init(scopes []string)
Init initialize the Token Manager. Generate token for the given scopes. Must run before using the Token Manager.
func (*PasswordRefreshTokenGrantManager) Token ¶
func (m *PasswordRefreshTokenGrantManager) Token() (string, error)
Token method returns an access token and any error occurred.