From 3f9ed2efaa7ff85cd622efabcb9990f06e961e0c Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 8 Oct 2018 08:39:58 +0200 Subject: [PATCH] stackdriver: wip - temp remove jwt token auth --- pkg/api/pluginproxy/ds_auth_provider.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/api/pluginproxy/ds_auth_provider.go b/pkg/api/pluginproxy/ds_auth_provider.go index b551a9a4d8a..5a8bf5605dd 100644 --- a/pkg/api/pluginproxy/ds_auth_provider.go +++ b/pkg/api/pluginproxy/ds_auth_provider.go @@ -64,11 +64,7 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route // } if ds.Type == "stackdriver" { - defaultCredentials, err := google.FindDefaultCredentials(ctx, "https://www.googleapis.com/auth/monitoring.read") - projectName := ds.JsonData.Get("defaultProject").MustString() - if projectName == "" { - ds.JsonData.Set("defaultProject", defaultCredentials.ProjectID) - } + defaultCredentials, err := google.FindDefaultCredentials(ctx, route.JwtTokenAuth.Scopes...) if err != nil { logger.Error("Failed to get default credentials", "error", err) } else { @@ -76,6 +72,7 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route if err != nil { logger.Error("Failed to get default access token", "error", err) } else { + ds.JsonData.Set("defaultProject", defaultCredentials.ProjectID) req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken)) } }