Commit 71af62e7 by Erik Sundell Committed by Daniel Lee

Stackdriver: Temporary exporting token lookup

parent 75c00264
......@@ -32,7 +32,8 @@ type jwtToken struct {
AccessToken string `json:"access_token"`
}
func newAccessTokenProvider(dsID int64, pluginRoute *plugins.AppPluginRoute) *accessTokenProvider {
// Access token provider
func NewAccessTokenProvider(dsID int64, pluginRoute *plugins.AppPluginRoute) *accessTokenProvider {
return &accessTokenProvider{
datasourceID: dsID,
route: pluginRoute,
......@@ -139,9 +140,21 @@ var getTokenSource = func(conf *jwt.Config, ctx context.Context) (*oauth2.Token,
return nil, err
}
logger.Info("interpolatedVal", "token.AccessToken", token.AccessToken)
return token, nil
}
func (provider *accessTokenProvider) getAccessTokenCacheKey() string {
return fmt.Sprintf("%v_%v_%v", provider.datasourceID, provider.route.Path, provider.route.Method)
}
//Export access token lookup
func GetAccessTokenFromCache(datasourceID int64, path string, method string) (string, error) {
key := fmt.Sprintf("%v_%v_%v", datasourceID, path, method)
if cachedToken, found := oauthJwtTokenCache[key]; found {
return cachedToken.AccessToken, nil
} else {
return "", fmt.Errorf("Key doesnt exist")
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment