Error when using OAuth2; 401 Unauthorized


Solved, was missing auth

Hi, I am having a problem with OAuth2.
After the SSO redirects to my “callback” page with the code param, when i use getAcessToken with ‘authorization_code’ as grant_type and params: [ ‘code’ => $_GET[‘code’], ‘redirect_uri’ => ‘’ ] the result returns ‘Error 401 Unauthorized’.

My client_id and secret are correct, not sure about the rest of the code:

const TOKEN_ENDPOINT         = '';

$params = array('code' => $_GET['code'], 'redirect_uri' => REDIRECT_URI);
$response = $client->getAccessToken(TOKEN_ENDPOINT, 'authorization_code', $params);

print_r($response); //401 here

parse_str($response['result'], $info);
$response = $client->fetch('');
var_dump($response, $response['result']);