How to use the tekore.Credentials function in tekore

To help you get started, we’ve selected a few tekore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github felix-hilden / spotipy / tests / auth / expiring.py View on Github external
def test_refresh_valid_refresh_interpreted_as_user_token(self):
        c = Credentials('id', 'secret', 'uri')
        token = MagicMock()
        token.refresh_token = 'refresh'

        mock = MagicMock()
        with patch(module + '.Credentials.refresh_user_token', mock):
            c.refresh(token)
            mock.assert_called_once()
github felix-hilden / spotipy / tests / auth / expiring.py View on Github external
def test_user_authorisation_url(self):
        c = Credentials('id', 'secret', 'uri')
        url = c.user_authorisation_url('scope', 'state', True)
        assert 'scope=scope' in url
        assert 'state=state' in url
        assert 'show_dialog=true' in url
github felix-hilden / spotipy / tests / auth / expiring.py View on Github external
def test_credentials_init_redirect_uri_optional(self):
        Credentials('id', 'secret')
github felix-hilden / spotipy / tests / auth / expiring.py View on Github external
def test_user_authorisation_url_accepts_scope_list(self):
        c = Credentials('id', 'secret', 'uri')
        url = c.user_authorisation_url(['a', 'b'], 'state', True)
        assert 'scope=a+b' in url
github felix-hilden / spotipy / tests / auth / expiring.py View on Github external
def test_refresh_user_token_refresh_replaced_if_returned(self):
        c = Credentials('id', 'secret', 'uri')
        token = make_token_dict()
        response = mock_response(content=token)

        send = MagicMock(return_value=response)
        with patch(module + '.Credentials._send', send):
            refreshed = c.refresh_user_token('refresh')
            assert refreshed.refresh_token == token['refresh_token']
github felix-hilden / spotipy / tests / _cred.py View on Github external
def setUpClass(cls):
        super().setUpClass()

        cls.cred = tk.Credentials(
            cls.client_id,
            cls.client_secret,
            cls.redirect_uri
        )

        try:
            cls.app_token = cls.cred.request_client_token()
        except tk.HTTPError as error:
            skip_or_fail(
                tk.HTTPError,
                'Error in retrieving application token!',
                error
            )

        sender = tk.RetryingSender(sender=tk.PersistentSender())
        cls.client = tk.Spotify(cls.app_token, sender=sender)
github felix-hilden / spotipy / tests / auth / expiring.py View on Github external
def test_request_client_token(self, app_env):
        c = Credentials(app_env[0], app_env[1])
        token = c.request_client_token()
        assert token.refresh_token is None
github felix-hilden / spotipy / tests / auth / expiring.py View on Github external
def test_refresh_none_refresh_interpreted_as_client_token(self):
        c = Credentials('id', 'secret', 'uri')
        token = MagicMock()
        token.refresh_token = None

        mock = MagicMock()
        with patch(module + '.Credentials.request_client_token', mock):
            c.refresh(token)
            mock.assert_called_once()
github felix-hilden / spotipy / tests / auth / expiring.py View on Github external
def test_server_error_raises_http_error(self):
        c = Credentials('id', 'secret')

        send = MagicMock(return_value=mock_response(500))
        with patch(module + '.Credentials._send', send):
            with pytest.raises(HTTPError):
                c.request_client_token()