def METHOD_NAME(self):
    server = self.create_server()
    data = {'response_type': 'code', 'client_id': 'client'}
    request = self.factory.post('/authorize', data=data)
    grant_user = User.objects.get(username='foo')
    resp = server.create_authorization_response(request, grant_user=grant_user)
    self.assertEqual(resp.status_code, 302)
    params = dict(url_decode(urlparse.urlparse(resp['Location']).query))
    code = params['code']
    request = self.factory.post(
        '/oauth/token',
        data={'grant_type': 'authorization_code', 'code': code},
        HTTP_AUTHORIZATION=self.create_basic_auth('client', 'secret'),
    )
    resp = server.create_token_response(request)
    self.assertEqual(resp.status_code, 200)
    data = json.loads(resp.content)
    return data