diff --git a/play-dl/Spotify/index.ts b/play-dl/Spotify/index.ts index 271f672..16b29fd 100644 --- a/play-dl/Spotify/index.ts +++ b/play-dl/Spotify/index.ts @@ -237,10 +237,10 @@ export async function refreshToken(): Promise { return true; } -export function setSpotifyToken(options: SpotifyDataOptions) { +export async function setSpotifyToken(options: SpotifyDataOptions) { spotifyData = options; spotifyData.file = false; - refreshToken(); + await refreshToken(); } export { SpotifyTrack, SpotifyAlbum, SpotifyPlaylist }; diff --git a/play-dl/token.ts b/play-dl/token.ts index 514bca7..87c4e65 100644 --- a/play-dl/token.ts +++ b/play-dl/token.ts @@ -39,14 +39,23 @@ interface tokenOptions { * } * }) // YouTube Cookies * + * await play.setToken({ + * spotify : { + * client_id: 'ID', + client_secret: 'secret', + refresh_token: 'token', + market: 'US' + * } + * }) // Await this only when setting data for spotify + * * play.setToken({ * useragent: ['Your User-agent'] * }) // Use this to avoid 429 errors. * ``` * @param options {@link tokenOptions} */ -export function setToken(options: tokenOptions) { - if (options.spotify) setSpotifyToken(options.spotify); +export async function setToken(options: tokenOptions) { + if (options.spotify) await setSpotifyToken(options.spotify); if (options.soundcloud) setSoundCloudToken(options.soundcloud); if (options.youtube) setCookieToken(options.youtube); if (options.useragent) setUserAgent(options.useragent);