Example #1
0
def generate_token():
    """Method that returns a spotipy Spotify API token for a given username, if the user
    gave the permission to connect the app with their account.
    If the token could not be generated, TokenGenerationException is raised."""
    return util.prompt_for_user_token(properties.MODIFY_PLAYLISTS_SCOPE,
                                      properties.SPOTIFY_API_ID,
                                      properties.SPOTIFY_API_SECRET,
                                      properties.SPOTIFY_REDIRECT_URL)
    def test_prompt_for_user_token(self):
        """Method that tests token generation both successful and with exception raised."""
        self.assertRaises(spotipy.SpotifyException, util.prompt_for_user_token)

        token = util.prompt_for_user_token(properties.MODIFY_PLAYLISTS_SCOPE,
                                           properties.SPOTIFY_API_ID,
                                           properties.SPOTIFY_API_SECRET,
                                           properties.SPOTIFY_REDIRECT_URL)
        self.assertIsNotNone(token)
    def test_prompt_for_user_token(self):
        """Method that tests token generation both successful and with exception raised."""
        self.assertRaises(spotipy.SpotifyException,
                          util.prompt_for_user_token)

        token = util.prompt_for_user_token(properties.MODIFY_PLAYLISTS_SCOPE,
                                                   properties.SPOTIFY_API_ID,
                                                   properties.SPOTIFY_API_SECRET,
                                                   properties.SPOTIFY_REDIRECT_URL)
        self.assertIsNotNone(token)
def generate_token():
    """Method that returns a spotipy Spotify API token for a given username, if the user
    gave the permission to connect the app with their account.
    If the token could not be generated, TokenGenerationException is raised."""
    return util.prompt_for_user_token(
        properties.MODIFY_PLAYLISTS_SCOPE,
        properties.SPOTIFY_API_ID,
        properties.SPOTIFY_API_SECRET,
        properties.SPOTIFY_REDIRECT_URL,
    )