Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
18b6b34b
Commit
18b6b34b
authored
Feb 01, 2019
by
Haines Chan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display access token in example app
parent
f1581ff8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
main.go
cmd/example-app/main.go
+8
-1
templates.go
cmd/example-app/templates.go
+5
-2
No files found.
cmd/example-app/main.go
View file @
18b6b34b
...
...
@@ -310,11 +310,18 @@ func (a *app) handleCallback(w http.ResponseWriter, r *http.Request) {
http
.
Error
(
w
,
fmt
.
Sprintf
(
"Failed to verify ID token: %v"
,
err
),
http
.
StatusInternalServerError
)
return
}
accessToken
,
ok
:=
token
.
Extra
(
"access_token"
)
.
(
string
)
if
!
ok
{
http
.
Error
(
w
,
"no access_token in token response"
,
http
.
StatusInternalServerError
)
return
}
var
claims
json
.
RawMessage
idToken
.
Claims
(
&
claims
)
buff
:=
new
(
bytes
.
Buffer
)
json
.
Indent
(
buff
,
[]
byte
(
claims
),
""
,
" "
)
renderToken
(
w
,
a
.
redirectURI
,
rawIDToken
,
token
.
RefreshToken
,
buff
.
Bytes
())
renderToken
(
w
,
a
.
redirectURI
,
rawIDToken
,
accessToken
,
token
.
RefreshToken
,
buff
.
Bytes
())
}
cmd/example-app/templates.go
View file @
18b6b34b
...
...
@@ -29,6 +29,7 @@ func renderIndex(w http.ResponseWriter) {
type
tokenTmplData
struct
{
IDToken
string
AccessToken
string
RefreshToken
string
RedirectURL
string
Claims
string
...
...
@@ -48,7 +49,8 @@ pre {
</style>
</head>
<body>
<p> Token: <pre><code>{{ .IDToken }}</code></pre></p>
<p> ID Token: <pre><code>{{ .IDToken }}</code></pre></p>
<p> Access Token: <pre><code>{{ .AccessToken }}</code></pre></p>
<p> Claims: <pre><code>{{ .Claims }}</code></pre></p>
{{ if .RefreshToken }}
<p> Refresh Token: <pre><code>{{ .RefreshToken }}</code></pre></p>
...
...
@@ -61,9 +63,10 @@ pre {
</html>
`
))
func
renderToken
(
w
http
.
ResponseWriter
,
redirectURL
,
idToken
,
refreshToken
string
,
claims
[]
byte
)
{
func
renderToken
(
w
http
.
ResponseWriter
,
redirectURL
,
idToken
,
accessToken
,
refreshToken
string
,
claims
[]
byte
)
{
renderTemplate
(
w
,
tokenTmpl
,
tokenTmplData
{
IDToken
:
idToken
,
AccessToken
:
accessToken
,
RefreshToken
:
refreshToken
,
RedirectURL
:
redirectURL
,
Claims
:
string
(
claims
),
...
...
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