NEW API - Problem in very simple request.

Hi,

I’m trying to create with the new API a simple call that returns some user information as shown in the official documentation here

My problem is the call CURL and do not know what I’m doing wrong, I create a php file with this code ( I have already got the access token after executing the authentication ):

<?php

$n_access_token = "xxxxxxxxxxxxxxxxx";

//prepare parameters
$url = 'https://api.envato.com/v1/market/private/user/account.json';
$headers = 'Authorization: Bearer '.$n_access_token;

//start
$ch = curl_init();

//settings
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);

//run
curl_exec($ch);

//close
curl_close($ch);

?>

The page shows me this:

{"error":"access_denied","error_description":"Bearer token not found"}

Please Help me

CURLOPT_HTTPHEADER accepts an array, with each element in the array being a single header, so it should be:

$headers = array('Authorization: Bearer '.$n_access_token);

Thanks for the reply :slight_smile: but now I see this message:

{“error”:"Scopes not matching. Expected [“user:account”] ",“code”:“not_authenticated”}

this is strange because I just ran the authentication, any ideas?

:sweat:

Afraid not on this one as I’ve never used the Envato API :frowning: Hopefully someone else who’s used it can assist!

Ensure all permissions are ticked on your token settings

Thanks ! Now it works !! :grinning:

1 Like