Skip to content

Commit

Permalink
Spotify bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
DxsSucuk committed Jul 5, 2023
1 parent a50fdd1 commit 59bb9ec
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ public SpotifyAPIHandler() {
* @throws IOException if there was a network error.
*/
public void initSpotify() throws ParseException, SpotifyWebApiException, IOException {
if (!isSpotifyConnected) return;
if (isSpotifyConnected) return;

this.spotifyApi = new SpotifyApi.Builder().setClientId(Main.getInstance().getConfig().getConfiguration().getString("spotify.client.id")).setClientSecret(Main.getInstance().getConfig().getConfiguration().getString("spotify.client.secret")).build();

try {
ClientCredentialsRequest.Builder request = new ClientCredentialsRequest.Builder(spotifyApi.getClientId(), spotifyApi.getClientSecret());
ClientCredentials credentials = request.grant_type("client_credentials").build().execute();
spotifyApi.setAccessToken(credentials.getAccessToken());
isSpotifyConnected = true;
} catch (Exception exception) {
if (exception.getMessage().equalsIgnoreCase("Invalid client")) {
log.warn("Spotify Credentials are invalid, you can ignore this if you don't use Spotify.");
Expand Down

0 comments on commit 59bb9ec

Please sign in to comment.