# Buggy code
def redirect_uri(provider):
    if provider == "facebook":
        provider_class = FbOAuth()
    elif provider == "google":
        provider_class = GoogleOAuth()
    elif provider == "twitter":
        provider_class = TwitterOAuth()
    elif provider == "instagram":
        provider_class = InstagramOAuth()
    else:
        return make_response(jsonify(message="No support for {}".format(provider)), 404)
    url = (
        provider_class.get_auth_uri()
        + "?client_id="
        + provider_class.get_client_id()
        + "&redirect_uri="
        + provider_class.get_redirect_uri()
    )
    return make_response(jsonify(url=url), 200)


# Traceback (TypeError)
INFO:werkzeug:127.0.0.1 - - [17/Jul/2018 04:40:54] "GET /v1/auth/oauth/facebook HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/media/srv_twry/work/Projects/Community-Projects/Fossasia/open-event-server/app/__init__.py", line 66, in __call__
return self.app(environ, start_response)
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/home/srv_twry/anaconda3/envs/open-event-server/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/media/srv_twry/work/Projects/Community-Projects/Fossasia/open-event-server/app/api/auth.py", line 39, in redirect_uri
provider_class.get_client_id() + '&amp;redirect_uri=' +\
TypeError: must be str, not NoneType

# Fixed code
def redirect_uri(provider):
    if provider == "facebook":
        provider_class = FbOAuth()
    elif provider == "google":
        provider_class = GoogleOAuth()
    elif provider == "twitter":
        provider_class = TwitterOAuth()
    elif provider == "instagram":
        provider_class = InstagramOAuth()
    else:
        return make_response(jsonify(message="No support for {}".format(provider)), 404)

    client_id = provider_class.get_client_id()
    if not client_id:
        return make_response(
            jsonify(
                message="{} client id is not configured on the server".format(provider)
            ),
            404,
        )

    url = (
        provider_class.get_auth_uri()
        + "?client_id="
        + client_id
        + "&redirect_uri="
        + provider_class.get_redirect_uri()
    )
    return make_response(jsonify(url=url), 200)