def test_token_by_client_credentials(self):

        user_1 = User(username='Fred')
        user_1.set_password('12345')
        user_1.save()

        client_1 = Client(user=user_1, title='OClient', identifier='OClient', password='cl012345')
        client_1.save()

        redirect_1 = RedirectionEndpoint(client=client_1, uri='http://redirect-test.com')
        redirect_1.save()

        Scope(identifier='scope1').save()

        # Valid token by client credentials request.
        resp = self.client.post(URL_TOKEN, {'grant_type': 'client_credentials', 'scope': 'scope1'},
                                Authorization='Basic T0NsaWVudDpjbDAxMjM0NQ==')

        self.assertEqual(resp.status_code, 200)
        self.assertTrue('access_token' in resp.content_json)
        self.assertTrue('refresh_token' not in resp.content_json)
        self.assertTrue('token_type' in resp.content_json)

        access_token = resp.content_json['access_token']
        token = Token.objects.get(access_token=access_token)
        self.assertEqual(user_1, token.user)
dataset/ETHPy150Open idlesign/django-oauthost/oauthost/tests.py/GrantsCheck.test_token_by_client_credentials/original