"Member 0 does not have permission to get company" error when trying to access LinkedIn company updates

827 Views Asked by At

I've had the client approve my user as an administrator after I created my application through LinkedIn's Developer backend. I even had the client create their OWN application and provide me the client keys for it, however I'm getting the same error message every time when trying to pull the company updates:

"Member 0 does not have permission to get company 1311XXX"

Here's my code for that page:

$config['base_url']             =   'http://www.hiddenlink.com/resources/li-oauth-src/auth.php';
$config['callback_url']         =   'http://www.hiddenlink.com/resources/li-oauth-src/demo.php';
$config['linkedin_access']      =   '770lXXXXXXXXXX';
$config['linkedin_secret']      =   'hcxpOtXXXXXXXXXX';

include_once "linkedin.php";

# First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
$linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['callback_url'] );
//$linkedin->debug = true;

if (isset($_REQUEST['oauth_verifier'])){
    $_SESSION['oauth_verifier']     = $_REQUEST['oauth_verifier'];

    $linkedin->request_token    =   unserialize($_SESSION['requestToken']);
    $linkedin->oauth_verifier   =   $_SESSION['oauth_verifier'];
    $linkedin->getAccessToken($_REQUEST['oauth_verifier']);

    $_SESSION['oauth_access_token'] = serialize($linkedin->access_token);
    header("Location: " . $config['callback_url']);
    exit;
}
else{
    $linkedin->request_token    =   unserialize($_SESSION['requestToken']);
    $linkedin->oauth_verifier   =   $_SESSION['oauth_verifier'];
    $linkedin->access_token     =   unserialize($_SESSION['oauth_access_token']);
}

$json_response = $linkedin->getCompanyUpdates("1311XXX");
$json = json_decode($json_response);
echo "<pre>";
print_r($json);
echo "</pre>";

for($x = 0; $x < 2; $x++){
    $json_value = $json->values[$x];
    $articleURL = $json_value->updateContent->companyStatusUpdate->share->content->eyebrowUrl;
    $postTitle = $json_value->updateContent->companyStatusUpdate->share->content->title;
    $description = htmlspecialchars($json_value->updateContent->companyStatusUpdate->share->content->description);
    $timestamp = $json_value->updateContent->companyStatusUpdate->share->timestamp;
    echo '<pre>';
    print_r($description);
    echo '<br />';
    print_r($articleURL);
    echo '<br />';
    print_r($postTitle);
    print_r(date("jS M, Y", $timestamp));
    echo '</pre>';
}

Here is the code for the getCompanyUpdates function being called for the json_response variable:

function getCompanyUpdates($id){
    $updateURL = $this->base_url . "/v1/companies/" . $id . "/updates?format=json";
    $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "GET", $updateURL);
    $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
    $auth_header = $request->to_header("https://api.linkedin.com"); # this is the realm
    $response = $this->httpRequest($updateURL, $auth_header, "GET");
    return $response;
}

I have zero clue what I'm doing wrong, but it's clear I'm doing something wrong. Any help would be much appreciated

1

There are 1 best solutions below

0
On

You don't seem to be explicitly passing a scope value anywhere in your oauth workflow, so I can only presume you are relying on your LinkedIn application's default scope values to be configured correctly.

Check to make sure you are requesting the rw_company_admin member permission when attempting to make that API call.