MCPcopy Create free account
hub / github.com/UiPath/uipathcli / Auth

Method Auth

auth/oauth_authenticator.go:36–49  ·  view source on GitHub ↗
(ctx AuthenticatorContext)

Source from the content-addressed store, hash-verified

34const offlineAccessScope = "offline_access"
35
36func (a OAuthAuthenticator) Auth(ctx AuthenticatorContext) AuthenticatorResult {
37 if !a.enabled(ctx) {
38 return *AuthenticatorSuccess(nil)
39 }
40 config, err := a.getConfig(ctx)
41 if err != nil {
42 return *AuthenticatorError(fmt.Errorf("Invalid oauth authenticator configuration: %w", err))
43 }
44 token, err := a.retrieveToken(*config, ctx)
45 if err != nil {
46 return *AuthenticatorError(fmt.Errorf("Error retrieving access token: %w", err))
47 }
48 return *AuthenticatorSuccess(NewBearerToken(token))
49}
50
51func (a OAuthAuthenticator) retrieveToken(config oauthAuthenticatorConfig, ctx AuthenticatorContext) (string, error) {
52 tokenResponse := a.getAccessTokenFromCache(config)

Calls 6

enabledMethod · 0.95
getConfigMethod · 0.95
retrieveTokenMethod · 0.95
AuthenticatorSuccessFunction · 0.85
AuthenticatorErrorFunction · 0.85
NewBearerTokenFunction · 0.85

Tested by 5

TestOAuthFlowIsCachedFunction · 0.76
callAuthenticatorFunction · 0.76