diff --git a/pkg/lib/template/oauth2_helper.go b/pkg/lib/template/oauth2_helper.go index 1ac150f..f4e4b3f 100644 --- a/pkg/lib/template/oauth2_helper.go +++ b/pkg/lib/template/oauth2_helper.go @@ -14,7 +14,7 @@ type oAuth2TokenExtended struct { // ReadOAuthReturnValue checks the return values from an OAUTH client and // stores the error in an extended struct of the oAuth token -func readOAuthReturnValue(t *oauth2.Token, err error) (tE oAuth2TokenExtended, err2 error) { +func readOAuthReturnValue(t *oauth2.Token, err error) (tE oAuth2TokenExtended) { if t == nil { t = &oauth2.Token{} // Make sure we have "AccessToken" in our struct } @@ -30,5 +30,5 @@ func readOAuthReturnValue(t *oauth2.Token, err error) (tE oAuth2TokenExtended, e } } } - return tE, err + return tE } diff --git a/pkg/lib/template/template_loader.go b/pkg/lib/template/template_loader.go index 398e848..64a2590 100644 --- a/pkg/lib/template/template_loader.go +++ b/pkg/lib/template/template_loader.go @@ -370,35 +370,35 @@ func (loader *Loader) Render( } return reflect.ValueOf(v).IsZero() }, - "oauth2_password_token": func(client string, login string, password string) (tE oAuth2TokenExtended, err error) { + "oauth2_password_token": func(client string, login string, password string) (tE oAuth2TokenExtended) { oAuthClient, ok := loader.OAuthClient[client] if !ok { - return tE, errors.Errorf("OAuth client %s not configured", client) + return readOAuthReturnValue(nil, errors.Errorf("OAuth client %q not configured", client)) } oAuthClient.Client = client return readOAuthReturnValue(oAuthClient.GetPasswordCredentialsAuthToken(login, password)) }, - "oauth2_client_token": func(client string) (tE oAuth2TokenExtended, err error) { + "oauth2_client_token": func(client string) (tE oAuth2TokenExtended) { oAuthClient, ok := loader.OAuthClient[client] if !ok { - return tE, errors.Errorf("OAuth client %s not configured", client) + return readOAuthReturnValue(nil, errors.Errorf("OAuth client %q not configured", client)) } oAuthClient.Client = client return readOAuthReturnValue(oAuthClient.GetClientCredentialsAuthToken()) }, - "oauth2_code_token": func(client string, params ...string) (tE oAuth2TokenExtended, err error) { + "oauth2_code_token": func(client string, params ...string) (tE oAuth2TokenExtended) { oAuthClient, ok := loader.OAuthClient[client] if !ok { - return tE, errors.Errorf("OAuth client %s not configured", client) + return readOAuthReturnValue(nil, errors.Errorf("OAuth client %q not configured", client)) } oAuthClient.Client = client return readOAuthReturnValue(oAuthClient.GetCodeAuthToken(params...)) }, - "oauth2_implicit_token": func(client string, params ...string) (tE oAuth2TokenExtended, err error) { + "oauth2_implicit_token": func(client string, params ...string) (tE oAuth2TokenExtended) { oAuthClient, ok := loader.OAuthClient[client] if !ok { - return tE, errors.Errorf("OAuth client %s not configured", client) + return readOAuthReturnValue(nil, errors.Errorf("OAuth client %q not configured", client)) } oAuthClient.Client = client return readOAuthReturnValue(oAuthClient.GetAuthToken(params...))