Getting Started with the Deezer API

Learn how to generate an OAuth access token to access the Deezer API endpoints.

To use the Deezer API, we first need to create an account.

Create an account

We can sign up for a Deezer account on their official page. Please follow the steps mentioned below to sign up:

  1. Click the “Login” button in the top-right corner.
  2. Click the “Register here” button under the login button to create a new account.
  3. Fill in your username, email address, password, age, and identity in their respective fields. Mark the checkbox for “I’m not a robot” and click the “Sign up” button.
  4. You have successfully signed up! Use the same credentials to log in.

The slides below will help you visualize the process:

Create a new application

After logging in, you have to create a new application to get the application ID and secret key. Follow the steps given below:

  1. Click the “My Apps” button in the top-right corner.
  2. Click the “Create a new Application” button.
  3. Fill in the required information.
    • You can enter any link, for example, http://www.example.com, for the “Link to your Terms of Use” field.
    • In the “Domain” field write educative.run and in “Redirect URL after authentication”, paste the link given below. This is a user-specific link assigned by Educative to every user.
Press + to interact
{{EDUCATIVE_LIVE_VM_URL}}
  1. Click the “Create” button.

  2. Your application is created and you can view your “Application ID” and “Secret Key”.

The slides below will help you visualize the process:

To save your application ID and secret key, scroll down and click the “Edit” button in the code widget below and enter these values in the APP_ID and SECRET_KEY fields. Then click the “Save” button.

App authorization

In server-side flow, we’re required to redirect users to the deezer.com domain in order to verify the user’s identity. We’ll do so by using the following URL:

https://connect.deezer.com/oauth/auth.php?
app_id=YOUR_APP_ID&redirect_uri=YOUR_REDIRECT_URI&perms=basic_access,email

If the user is not connected, then the Deezer login page will open so that they can be authenticated.

Note: Refer to the User Permissions and API Errors Codes lesson in the appendix to learn more about user permissions.

Once user authentication is done, Deezer will ask the user to authorize the permissions that the application is requesting. If the user clicks the “Accept” button, then the user is redirected to the redirect_uri with the parameter code.

http://redirect_uri?code=A_CODE_GENERATED_BY_DEEZER

Getting the access token

We’ll get our access token by using the following API:

https://connect.deezer.com/oauth/access_token.php?
app_id=YOU_APP_ID&secret=YOU_APP_SECRET&code=THE_CODE_FROM_ABOVE

Click the “Run” button in the code widget below to get the access token.

{
  "name": "access-token",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^0.27.2",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.3.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "PORT=8080 react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
Getting the Access Token

Verify the access token

Click the “Edit” button to save the access token in the code widget below. Click “Run” to make sure that the access token is saved successfully.

Press + to interact
verifyToken('{{ACCESS_TOKEN}}')