Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Also redirect errors in getting token to the custom result page
Browse files Browse the repository at this point in the history
Otherwise cancelling the OAuth process results in a lame text-only page.
  • Loading branch information
jpcoenen committed Jul 3, 2020
1 parent d2966b1 commit b0214dd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions internals/oauthorizer/callback_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,20 @@ func (s CallbackHandler) handleRequest(callback func(string) error, done func())
var once sync.Once
var redirectURL *url.URL
return func(w http.ResponseWriter, r *http.Request) {
code, err := s.authorizer.ParseResponse(r, s.state)
if err != nil {
fmt.Fprintf(w, "Error: %s", err)
return
}

once.Do(func() {
err = callback(code)
redirectURL = s.baseRedirectURL
err := func() error {
code, err := s.authorizer.ParseResponse(r, s.state)
if err != nil {
return err
}

err = callback(code)
if err != nil {
return err
}
return nil
}()
if err != nil {
q := redirectURL.Query()
q.Set("error", err.Error())
Expand Down

0 comments on commit b0214dd

Please sign in to comment.