'Generates an authorization grant represented as a dictionary.'

def create_authorization_code(self, request):

    grant = {u'code': common.generate_token()}
    if (hasattr(request, u'state') and request.state):
        grant[u'state'] = request.state
    log.debug(u'Created    authorization    code    grant    %r    for    request    %r.', grant, request)
    return grant
