Deezer Javascript SDK on localhost

1.2k Views Asked by At

For developing I would like to use the Deezer Javascript SDK on localhost. I set the application domain on localhost:8000, but it didn't work. My HTML file is on localhost:8000:

<!DOCTYPE html>
<html>

<head>
  <title>Deezer to Spotify</title>
</head>

<body>
  <div id="dz-root"></div>
<script src="http://cdn-files.deezer.com/js/min/dz.js"></script>
<script src="DeezerToSpotifySwitcher.js" charset="utf-8"></script>
</body>

</html>

My javascript file:

DZ.init({
  appId: '147671',
  channelUrl: 'http://localhost:8000/DeezerToSpotifySwitcher.html'
});

DZ.login(function (response) {
    if (response.authResponse) {
        DZ.api('/user/me', function (response) {
            alert('Good to see you, ' + response.name + '.');
        });
    } else {
        alert('User cancelled login or did not fully authorize.');
    }
}, { perms: 'basic_access,email' });

What application domain do I have to set? Did I miss something else?

4

There are 4 best solutions below

0
On BEST ANSWER

I had the same issue, using domain deezer-dl.local:8888.

On https://connect.deezer.com/oauth/auth.php, it was displaying:

  You must enter a valid redirect uri

I solved the problem by fixing the Application Domain in Deezer applications' preferences to deezer-dl.local (without port) and using the standard 80 port for my application...

0
On

You can try with : channelUrl: 'http://yourAppDomain.com/channel.php'

or

channelUrl: 'http://yourAppDomain.com/channel.html

0
On

Try 127.0.0.1:8000 instead of localhost:8000. And don't forget to add it to permitted hosts as 127.0.0.0.1:8000. And you don't have to use 80 port in this case.

Worked perfectly for me.

0
On

It seems like it only works without explicit port definition - so just reconfigure your local server to run on port 80.