This line should be something like that (to match the rest)
 
    return 'Access denied: error=%s' % (flask.request.args['error'])

Cause it looks like GitHub returns only the error in the URL for example:

    http://127.0.0.1:5000/_s/callback/github/oauth-authorized/?error=redirect_uri_mismatch

Verify by having a different url in the settings..