|
@@ -64,7 +64,7 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if req.Header.Get("Authorization") == "" && ds.Type == "stackdriver" {
|
|
if req.Header.Get("Authorization") == "" && ds.Type == "stackdriver" {
|
|
|
- defaultCredentials, err := google.FindDefaultCredentials(ctx)
|
|
|
|
|
|
|
+ defaultCredentials, err := google.FindDefaultCredentials(ctx, "https://www.googleapis.com/auth/monitoring.read")
|
|
|
projectName := ds.JsonData.Get("defaultProject").MustString()
|
|
projectName := ds.JsonData.Get("defaultProject").MustString()
|
|
|
if projectName == "" {
|
|
if projectName == "" {
|
|
|
ds.JsonData.Set("defaultProject", defaultCredentials.ProjectID)
|
|
ds.JsonData.Set("defaultProject", defaultCredentials.ProjectID)
|
|
@@ -81,24 +81,6 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if req.Header.Get("Authorization") == "" && ds.Type == "stackdriver" {
|
|
|
|
|
- credentials, err := google.FindDefaultCredentials(ctx, "https://www.googleapis.com/auth/monitoring.read")
|
|
|
|
|
- projectName := ds.JsonData.Get("defaultProject").MustString()
|
|
|
|
|
- if projectName == "" {
|
|
|
|
|
- ds.JsonData.Set("defaultProject", credentials.ProjectID)
|
|
|
|
|
- }
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- logger.Error("Failed to get access token", "error", err)
|
|
|
|
|
- } else {
|
|
|
|
|
- token, err := credentials.TokenSource.Token()
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- logger.Error("Failed to get access token", "error", err)
|
|
|
|
|
- } else {
|
|
|
|
|
- req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken))
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
logger.Info("Requesting", "url", req.URL.String())
|
|
logger.Info("Requesting", "url", req.URL.String())
|
|
|
|
|
|
|
|
}
|
|
}
|