Could not verify the provided CSRF token because your session was not found.

API Discussion
Hello, I'm actually following https://develop.battle.net/documentation/api-reference/oauth-api instructions

First request is doing good

But when I try the second step : POST - /oauth/token

I have this error:

HTTP Status 403 - Could not verify the provided CSRF token because your session was not found.

here is my code :

$url = "https://eu.battle.net/oauth/userinfo";

///The data you want to send via POST
$fields = [
'grant_type' => 'authorization_code',
'code' => $_GET['code'],
'redirect_uri' => 'http://creahs.fr/uploader.php' ,
'client_id' => 'c143ae84941e46e7b99a5c4a0f8cc6ff'
];

//url-ify the data for the POST
$fields_string = http_build_query($fields);

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//So that curl_exec returns the contents of the cURL; rather than echoing it
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);

//execute post
$result = curl_exec($ch);
$info = curl_getinfo($ch);
var_dump($info);
var_dump($result);

If someone could help me it would be really nice :) thanks !

Join the Conversation

Return to Forum