Method called by Strava (redirect) that includes parameters.
    - state
    - code
    - error
18706
def logged_in():
    
    error = request.args.get('error')
    state = request.args.get('state')
    if error:
        return render_template('login_error.html', error=error)
    else:
        code = request.args.get('code')
        client = Client()
        access_token = client.exchange_code_for_token(client_id=app.config['STRAVA_CLIENT_ID'],
                                                      client_secret=app.config['STRAVA_CLIENT_SECRET'],
                                                      code=code)
        # Probably here you'd want to store this somewhere -- e.g. in a database.
        strava_athlete = client.get_athlete()

        return render_template('login_results.html', athlete=strava_athlete, access_token=access_token)
1089148
public static void sendError( String messageKey, Throwable cause, ServletRequest request,
                                  HttpServletResponse response, Object[] messageArgs )
            throws IOException
    {
        // TODO: the following null check will be unnecessary once the deprecated
        // FlowController.sendError(String, HttpServletResponse) is removed.
        boolean avoidDirectResponseOutput = request != null ? avoidDirectResponseOutput( request ) : false;
        sendError( messageKey, messageArgs, request, response, cause, avoidDirectResponseOutput );
    }
152809
def redirect(self, url, status=None):
        
        self.status_code = 302 if status is None else status
        self.headers = Headers([('location', url)])
        self.message = ''
        self.end()
643667
function errorHandler(err, req, res, next) {
  req.error = err;
  const errorHandlers = Route.routes('handler').filter((obj) => {
    return obj.target === req.url;
  });

  if(errorHandlers.length > 0) {
    return redirect(errorHandlers[0], req, res, next);
  }


  const errorRoute = Route.routes('err').filter((obj) => {
    return obj.extra.status === 500;
  });

  if(isDebug) {
    console.log(err.message);
  }

  if(errorRoute.length > 0) {
    return redirect(errorRoute[0], req, res, next, err);
  } else {
    app.set('view engine', 'ejs');
    res.status(500).render(`${__dirname}/src/assets/errors.ejs`, {
      status: 500,
      message: err.message
    });
  }
}
870087
function  (options, status) {
  this.name = ''
  this.error = options.error || 'invalid_request'
  this.error_description = options.error_description
  this.redirect_uri = options.redirect_uri
  this.statusCode = options.statusCode || 400
}
314631
function newError (state, action) {
  const { error } = action;

  return Object.assign({}, state, {
    visible: true,
    message: error.message,
    error
  });
}
1336990
def respond(request, code):
    
    redirect = request.GET.get('next', request.POST.get('next'))
    if redirect:
        return HttpResponseRedirect(redirect)
    return type('Response%d' % code, (HttpResponse, ), {'status_code': code})()
175264
function defaultError(view, location) {
	const code = (/^[45]\d\d$/).test(location.name) ? +location.name : 0;
	view.document.body['inner'+'HTML'] = `<h1 id="code"></h1><span id="message"></span>`
	+`<style> :root { background: #424F5A; filter: invert(1) hue-rotate(180deg); font-family: Segoe UI, Tahoma, sans-serif; } </style>`;
	view.document.querySelector('#message').textContent = code ? view.history.state && view.history.state.message || '' : `Unknown view "${ location.name }"`;
	view.document.querySelector('#code').textContent = code || 404;
	view.document.title = !code || code === 404 ? 'Not Found' : view.history.state && view.history.state.title || 'Error';
	!code && console.error(`Got unknown view "${ view.location.hash.slice(1) }"`);
	location.onChange(() => view.location.reload());
}
3894
function AccessDeniedError(message, innerMessage, model) {
    AccessDeniedError.super_.bind(this)('EACCESS', ('Access Denied' || message) , innerMessage, model);
    this.statusCode = 401;
}
493660
function(uri) {
        var route = this.defined(uri);
        if (route !== false) {

            if (this._routes[route].method === null) {
                var f = this._routes[route].handler.bind(this._routes[route].handler);
                f(this.params(route));
            } else {
                var Obj = this._routes[route].handler;
                var method = this._routes[route].method;
                Obj[method](this.params(route));
            }

        } else {
            console.error('Route "' + uri + '" is not defined.');
            return false;
        }
    }
294818
function handleRequestError(eventTarget, type) {
  readyStateChange(eventTarget, states.DONE);

  dispatchProgressEvent(eventTarget, {
    type: 'progress',
    total: 0,
    loaded: 0,
    lengthComputable: false
  });

  dispatchProgressEvent(eventTarget, {
    type: type,
    total: 0,
    loaded: 0,
    lengthComputable: false
  });

  dispatchProgressEvent(eventTarget, {
    type: 'loadend',
    total: 0,
    loaded: 0,
    lengthComputable: false
  });
}
891351
def redirect_exception(self, exception):
        

        from django.http import QueryDict, HttpResponseRedirect

        query = QueryDict("").copy()
        query["error"] = exception.error
        query["error_description"] = exception.reason
        query["state"] = self.state

        return HttpResponseRedirect(self.redirect_uri.url + "?" + query.urlencode())
849411
function HttpError (code, error, description) {
    this.statusCode = code;

    if (error instanceof Error)
        WError.call(this, error, description || httpErrors[this.statusCode].description);
    else
        WError.call(this, error || httpErrors[this.statusCode].description);

    return this;
}
6321
function(req, res) {
    var params = URL.parse(req.url, true).query
      , code = params.code
      , state = params.state
    ;

    if(!code) {
      res.writeHead(400, {'Content-Type': 'text/plain'});
      return res.end('The "code" parameter is missing.');
    }
    if(!state) {
      res.writeHead(400, {'Content-Type': 'text/plain'});
      return res.end('The "state" parameter is missing.');
    }
    try {
      state = this.serializer.parse(state);
    } catch(err) {
      res.writeHead(400, {'Content-Type': 'text/plain'});
      return res.end('The "state" parameter is invalid.');
    }
    var data = {
      oauth2_server_id: state[0]
      , next_url: state[1]
      , state: state[2]
    }
    var methods = this.methods[data.oauth2_server_id];
    methods.valid_grant(data, code, function(err, token) {
      if (err) return server_error(res, err);
      if(!token) {
        res.writeHead(400, {'Content-Type': 'text/plain'});
        res.end('Invalid grant.');
        return;
      }
      data.token = token;
      methods.treat_access_token(data, req, res, function() {
        redirect(res, data.next_url);
      }, function(err){server_error(res, err)});
    });
  }
585241
@Override
    public void error(String code, Object... arguments)
        throws NullPointerException, IllegalArgumentException {

        this.store.add(Level.ERROR, resolveMessage(code, arguments));
    }
385994
def error_handler(f):
    """"""
    @wraps(f)
    def decorated(*args, **kwargs):
        try:
            return f(*args, **kwargs)
        except OAuth2Error as e:
            # Only FatalClientError are handled by Flask-OAuthlib (as these
            # errors should not be redirect back to the client - see
            # http://tools.ietf.org/html/rfc6749#section-4.2.2.1)
            if hasattr(e, 'redirect_uri'):
                return redirect(e.in_uri(e.redirect_uri))
            else:
                return redirect(e.in_uri(oauth2.error_uri))
    return decorated
618151
def validate_redirect_uri(value):
    
    sch, netloc, path, par, query, fra = urlparse(value)
    if not (sch and netloc):
        raise InvalidRedirectURIError()
    if sch != 'https':
        if ':' in netloc:
            netloc, port = netloc.split(':', 1)
        if not (netloc in ('localhost', '127.0.0.1') and sch == 'http'):
            raise InsecureTransportError()