Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
71af62e7
Commit
71af62e7
authored
Sep 09, 2018
by
Erik Sundell
Committed by
Daniel Lee
Sep 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stackdriver: Temporary exporting token lookup
parent
75c00264
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletions
+14
-1
pkg/api/pluginproxy/access_token_provider.go
+14
-1
No files found.
pkg/api/pluginproxy/access_token_provider.go
View file @
71af62e7
...
@@ -32,7 +32,8 @@ type jwtToken struct {
...
@@ -32,7 +32,8 @@ type jwtToken struct {
AccessToken
string
`json:"access_token"`
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
{
return
&
accessTokenProvider
{
datasourceID
:
dsID
,
datasourceID
:
dsID
,
route
:
pluginRoute
,
route
:
pluginRoute
,
...
@@ -139,9 +140,21 @@ var getTokenSource = func(conf *jwt.Config, ctx context.Context) (*oauth2.Token,
...
@@ -139,9 +140,21 @@ var getTokenSource = func(conf *jwt.Config, ctx context.Context) (*oauth2.Token,
return
nil
,
err
return
nil
,
err
}
}
logger
.
Info
(
"interpolatedVal"
,
"token.AccessToken"
,
token
.
AccessToken
)
return
token
,
nil
return
token
,
nil
}
}
func
(
provider
*
accessTokenProvider
)
getAccessTokenCacheKey
()
string
{
func
(
provider
*
accessTokenProvider
)
getAccessTokenCacheKey
()
string
{
return
fmt
.
Sprintf
(
"%v_%v_%v"
,
provider
.
datasourceID
,
provider
.
route
.
Path
,
provider
.
route
.
Method
)
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"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment