<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def authorize_application( request, redirect_uri = 'https://%s/%s' % (FACEBOOK_APPLICATION_DOMAIN, FACEBOOK_APPLICATION_NAMESPACE), permissions = FACEBOOK_APPLICATION_INITIAL_PERMISSIONS ):
 """ Redirect the user to authorize the application. Redirection is done by rendering a JavaScript snippet that redirects the parent window to the authorization URI, since Facebook will not allow this inside an iframe. """

    query = {
        'client_id': FACEBOOK_APPLICATION_ID,
        'redirect_uri': redirect_uri
    }

    if permissions:
        query['scope'] = ', '.join(permissions)

    return render(
        request = request,
        template_name = 'fandjango/authorize_application.html',
        dictionary = {
            'url': 'https://www.facebook.com/dialog/oauth?%s' % urlencode(query)
        },
        status = 401
    )