async def test_inability_to_get_token_with_client_credentials(self, api: SpotifyApiClient):
        auth_code_flow = AuthorizationCodeFlow()
        auth_code_flow.load_from_env()

        api = SpotifyApiClient(auth_code_flow)
        with pytest.raises(SpotifyError):
            await api.get_auth_token_with_client_credentials()
Example #2
0
 def add_auth_code_flow():
     """
     Add auth_code_flow parameter
     """
     auth_code_flow = AuthorizationCodeFlow()
     auth_code_flow.load_from_env()
     auth_code_flow.scopes = TestDataTransfer.scopes
     TestDataTransfer.auth_code_flow = auth_code_flow
    async def test_authorization_code_flow(self, api: SpotifyApiClient):
        auth_code_flow = AuthorizationCodeFlow()
        auth_code_flow.load_from_env()
        auth_code_flow.scopes = TestDataTransfer.scopes

        api = SpotifyApiClient(auth_code_flow)
        code = await api.get_code_with_cookie(TestDataTransfer.cookies)
        await api.get_auth_token_with_code(code)
Example #4
0
    def add_api():
        """
        Add api parameter
        """
        auth_code_flow = AuthorizationCodeFlow()
        auth_code_flow.load_from_env()
        auth_code_flow.scopes = TestDataTransfer.scopes

        TestDataTransfer.api = SpotifyApiClient(auth_code_flow,
                                                hold_authentication=True)
Example #5
0
def api():
    """
    Returns: The an api instance
    """

    auth_code_flow = AuthorizationCodeFlow()
    auth_code_flow.load_from_env()
    auth_code_flow.scopes = TestDataTransfer.scopes

    api = SpotifyApiClient(auth_code_flow)
    return api
Example #6
0
    def __init__(self, bot):
        self.bot = bot
        self.games = {}

        if not bot.spy_client:
            auth_flow = AuthorizationCodeFlow(scopes=[])
            auth_flow.load_from_env()
            api_client = SpotifyApiClient(
                auth_flow,
                hold_authentication=True,
                token_renew_instance=TokenRenewClass())
            bot.spy_client = api_client
            bot.loop.create_task(self.connect_to_spotify())

        bot.loop.create_task(self.create_tables())
Example #7
0
async def prepared_api():
    """
    Returns: A ready to go api client
    """

    auth_code_flow = AuthorizationCodeFlow()
    auth_code_flow.load_from_env()
    auth_code_flow.scopes = TestDataTransfer.scopes

    api = SpotifyApiClient(auth_code_flow, hold_authentication=True)
    code = await api.get_code_with_cookie(TestDataTransfer.cookies)
    await api.get_auth_token_with_code(code)

    await api.create_new_client()

    yield api

    await api.close_client()
Example #8
0
    def test_docker_secret(self):

        p = AuthorizationCodeFlow()

        if os.environ.get('github_action'):
            p.load_from_docker_secret()
            assert p.application_id == 'wrong_id'
        else:
            p.load_from_docker_secret(
                '/home/niclas/IdeaProjects/AsyncSpotify/examples/private/')
            assert p.application_id == 'wrong_id'