Skip to content

Commit

Permalink
cmd/example-app: add option to not request a refresh token
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Chiang committed Jan 10, 2017
1 parent 0f4a1f6 commit 7866507
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/example-app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,15 @@ func (a *app) handleLogin(w http.ResponseWriter, r *http.Request) {

authCodeURL := ""
scopes = append(scopes, "openid", "profile", "email")
if a.offlineAsScope {
if r.FormValue("offline_acecss") != "yes" {
authCodeURL = a.oauth2Config(scopes).AuthCodeURL(exampleAppState)
} else if a.offlineAsScope {
scopes = append(scopes, "offline_access")
authCodeURL = a.oauth2Config(scopes).AuthCodeURL(exampleAppState)
} else {
authCodeURL = a.oauth2Config(scopes).AuthCodeURL(exampleAppState, oauth2.AccessTypeOffline)
}

http.Redirect(w, r, authCodeURL, http.StatusSeeOther)
}

Expand Down
3 changes: 3 additions & 0 deletions cmd/example-app/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ var indexTmpl = template.Must(template.New("index.html").Parse(`<html>
</p>
<p>
Extra scopes:<input type="text" name="extra_scopes" placeholder="list of scopes">
</p>
<p>
Request offline access:<input type="checkbox" name="offline_access" value="yes" checked>
</p>
<input type="submit" value="Login">
</form>
Expand Down

0 comments on commit 7866507

Please sign in to comment.