Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/base_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,19 @@ func (service *BaseService) Request(req *http.Request, result interface{}) (deta
authenticateError := service.Options.Authenticator.Authenticate(req)
if authenticateError != nil {
var authErr *AuthenticationError
var sdkErr *SDKProblem
if errors.As(authenticateError, &authErr) {
detailedResponse = authErr.Response
err = SDKErrorf(authErr.HTTPProblem, fmt.Sprintf(ERRORMSG_AUTHENTICATE_ERROR, authErr.Error()), "auth-failed", getComponentInfo())
} else {
} else if errors.As(authenticateError, &sdkErr) {
sdkErr := RepurposeSDKProblem(authenticateError, "auth-failed")
// For compatibility.
sdkErr.(*SDKProblem).Summary = fmt.Sprintf(ERRORMSG_AUTHENTICATE_ERROR, authenticateError.Error())
err = sdkErr
} else {
// External authenticators that implement the core interface might return a standard error.
// Handle that by wrapping it here.
err = SDKErrorf(err, fmt.Sprintf(ERRORMSG_AUTHENTICATE_ERROR, authErr.Error()), "custom-auth-failed", getComponentInfo())
}
return
}
Expand Down