code: 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
docs: Handle uncaught OAuth errors.