I've tried to get my access token for the deezer API but i keep getting the 'wrong code' message when i send my request. Here is the said request :
'https://connect.deezer.com/oauth/access_token.php?app_id=' + appID + '&secret=' + clientSecret + '&code=' + code;
The app ID and the client secret are located on developers.deezer.com/myapps so i can't be wrong with these two.
For the code i'm using a php code sample given by deezer themself (you can look it up here : https://developers.deezer.com/api/oauth) The said sample code is a simple page that makes you agree to let your application your data, as usual. At the end you're redirected to an empty page with an url like this one (don't worry, the code and scope are fake) :
http://localhost/deezerAPI/test1.php?code=fr14364f27b39760284c5698&state=27f24b97ab810mb3176d42fh
Anyway, I've copy and pasted the (fake) code fr14364f27b39760284c5698 to a self made node js program (why nodejs? because i'm much more comfortable using node to send requests) (also, the values here are fake too) :
'use strict';
const express = require('express');
var request = require('request');
const app = new express();
var appID = '<appId>'
var clientSecret = '<clientSecret>';
var code = 'fr14364f27b39760284c5698'
var requestURI = 'https://connect.deezer.com/oauth/access_token.php?app_id=' + appID + '&secret=' + clientSecret + '&code=' + code;
request(requestURI, (error, response, body) => {
console.log("Recieved body'" + body + "'");
});
app.listen(8081, () => {
console.log("WebClient is up!");
});
And every time i recieve the body 'wrong code'. To me it can only mean two things :
the php code sample deezer gave me is wrong or i wrote something wrong in it (like the app ID or client secret) but that's unlikely since i've checked what i wrote several time.
the node js code i made is wrong (in the way i make my request for exemple) or, like before, the info i've put is wrong (but i've also checked several times...). I'm out of solutions so if you guys have any clue, tell me. Thanks in advance.
PS: if you want to see the deezer code sample tell me, what i have on my wamp server isn't different from what they have but maybe you'll see something that doesn't add up.
https://connect.deezer.com/oauth/auth.php?app_id=YOUR_APP_ID&redirect_uri=YOUR_REDIRECT_URI&perms=basic_access,email
CODE
param. You can get this code and use it to get access token in next step. * REDIRECT_URI
could be something like this. http://localhost/deezerAPI/test1.php
. So you can get CODE
param in this file.https://connect.deezer.com/oauth/access_token.php?app_id=YOU_APP_ID&secret=YOU_APP_SECRET&code=THE_CODE_FROM_ABOVE
CODE
you just received, then you can get access token. Now you can make any API requests with this access token. That's it