Documentation ¶
Overview ¶
Package base contains a "Base" client that is used by the external public.Client and confidential.Client. Base holds shared attributes that must be available to both clients and methods that act as shared calls.
Index ¶
- Constants
- type AcquireTokenAuthCodeParameters
- type AcquireTokenOnBehalfOfParameters
- type AcquireTokenSilentParameters
- type AuthResult
- type Client
- func (b Client) Account(ctx context.Context, homeAccountID string) (shared.Account, error)
- func (b Client) AcquireTokenByAuthCode(ctx context.Context, authCodeParams AcquireTokenAuthCodeParameters) (AuthResult, error)
- func (b Client) AcquireTokenOnBehalfOf(ctx context.Context, onBehalfOfParams AcquireTokenOnBehalfOfParameters) (AuthResult, error)
- func (b Client) AcquireTokenSilent(ctx context.Context, silent AcquireTokenSilentParameters) (AuthResult, error)
- func (b Client) AllAccounts(ctx context.Context) ([]shared.Account, error)
- func (b Client) AuthCodeURL(ctx context.Context, clientID, redirectURI string, scopes []string, ...) (string, error)
- func (b Client) AuthResultFromToken(ctx context.Context, authParams authority.AuthParams, ...) (AuthResult, error)
- func (b Client) RemoveAccount(ctx context.Context, account shared.Account) error
- type Option
- func WithCacheAccessor(ca cache.ExportReplace) Option
- func WithClientCapabilities(capabilities []string) Option
- func WithInstanceDiscovery(instanceDiscoveryEnabled bool) Option
- func WithKnownAuthorityHosts(hosts []string) Option
- func WithRegionDetection(region string) Option
- func WithX5C(sendX5C bool) Option
Constants ¶
const (
// AuthorityPublicCloud is the default AAD authority host
AuthorityPublicCloud = "https://login.microsoftonline.com/common"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcquireTokenAuthCodeParameters ¶
type AcquireTokenAuthCodeParameters struct { Scopes []string Code string Challenge string Claims string RedirectURI string AppType accesstokens.AppType Credential *accesstokens.Credential TenantID string }
AcquireTokenAuthCodeParameters contains the parameters required to acquire an access token using the auth code flow. To use PKCE, set the CodeChallengeParameter. Code challenges are used to secure authorization code grants; for more information, visit https://tools.ietf.org/html/rfc7636.
type AcquireTokenOnBehalfOfParameters ¶ added in v0.4.0
type AcquireTokenOnBehalfOfParameters struct { Scopes []string Claims string Credential *accesstokens.Credential TenantID string UserAssertion string }
type AcquireTokenSilentParameters ¶
type AcquireTokenSilentParameters struct { Scopes []string Account shared.Account RequestType accesstokens.AppType Credential *accesstokens.Credential IsAppCache bool TenantID string UserAssertion string AuthorizationType authority.AuthorizeType Claims string AuthnScheme authority.AuthenticationScheme }
AcquireTokenSilentParameters contains the parameters to acquire a token silently (from cache).
type AuthResult ¶
type AuthResult struct { Account shared.Account IDToken accesstokens.IDToken AccessToken string ExpiresOn time.Time GrantedScopes []string DeclinedScopes []string }
AuthResult contains the results of one token acquisition operation in PublicClientApplication or ConfidentialClientApplication. For details see https://aka.ms/msal-net-authenticationresult
func AuthResultFromStorage ¶
func AuthResultFromStorage(storageTokenResponse storage.TokenResponse) (AuthResult, error)
AuthResultFromStorage creates an AuthResult from a storage token response (which is generated from the cache).
func NewAuthResult ¶
func NewAuthResult(tokenResponse accesstokens.TokenResponse, account shared.Account) (AuthResult, error)
NewAuthResult creates an AuthResult.
type Client ¶
type Client struct { Token *oauth.Client AuthParams authority.AuthParams // DO NOT EVER MAKE THIS A POINTER! See "Note" in New(). // contains filtered or unexported fields }
Client is a base client that provides access to common methods and primatives that can be used by multiple clients.
func New ¶
func New(clientID string, authorityURI string, token *oauth.Client, options ...Option) (Client, error)
New is the constructor for Base.
func (Client) AcquireTokenByAuthCode ¶
func (b Client) AcquireTokenByAuthCode(ctx context.Context, authCodeParams AcquireTokenAuthCodeParameters) (AuthResult, error)
func (Client) AcquireTokenOnBehalfOf ¶ added in v0.4.0
func (b Client) AcquireTokenOnBehalfOf(ctx context.Context, onBehalfOfParams AcquireTokenOnBehalfOfParameters) (AuthResult, error)
AcquireTokenOnBehalfOf acquires a security token for an app using middle tier apps access token.
func (Client) AcquireTokenSilent ¶
func (b Client) AcquireTokenSilent(ctx context.Context, silent AcquireTokenSilentParameters) (AuthResult, error)
func (Client) AllAccounts ¶
func (Client) AuthCodeURL ¶
func (b Client) AuthCodeURL(ctx context.Context, clientID, redirectURI string, scopes []string, authParams authority.AuthParams) (string, error)
AuthCodeURL creates a URL used to acquire an authorization code.
func (Client) AuthResultFromToken ¶
func (b Client) AuthResultFromToken(ctx context.Context, authParams authority.AuthParams, token accesstokens.TokenResponse, cacheWrite bool) (AuthResult, error)
type Option ¶
Option is an optional argument to the New constructor.
func WithCacheAccessor ¶
func WithCacheAccessor(ca cache.ExportReplace) Option
WithCacheAccessor allows you to set some type of cache for storing authentication tokens.
func WithClientCapabilities ¶ added in v0.8.0
WithClientCapabilities allows configuring one or more client capabilities such as "CP1"
func WithInstanceDiscovery ¶ added in v0.8.0
func WithKnownAuthorityHosts ¶ added in v0.7.0
WithKnownAuthorityHosts specifies hosts Client shouldn't validate or request metadata for because they're known to the user