# Problem to consume Linkedin API

**URL:** <https://discourse.cakephp.org/t/problem-to-consume-linkedin-api/2770>\
**Category:** Uncategorized\
**Created:** [June 22, 2017, 9:13pm UTC](https://discourse.cakephp.org/t/problem-to-consume-linkedin-api/2770 "2017-06-22T21:13:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcelo](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Marcelo](https://discourse.cakephp.org/u/Marcelo)\
**Post date:** [June 22, 2017, 9:13pm UTC](https://discourse.cakephp.org/t/problem-to-consume-linkedin-api/2770/1 "2017-06-22T21:13:34Z")

</div>

Hello guys, good night!

I’m developing an app to consume the Linkedin API and use the basic information of users to our new system.

But there is one step who isn’t work at time…when I call this method and debug the  
token …some errror message is exibited to me

```
   $params = [
            'grant_type' => $this->grantType,
            'client_id' => $this->clientID,
            'client_secret' => $this->clientSecret,
            'code' => $this->request->query['code'],
            'redirect_uri' => $this->callbackURL,
        ];
        

        $http = new Client();
        $response = $http->get('https://www.linkedin.com/uas/oauth2/accessToken', $params);
        $token = json_decode($response->body);
        
        debug($token);
                    
        $user_linkedin = $this->_fetchLinkedin('/v1/people/~:(firstName,lastName,emailAddress)', $token->access_token);

```

ERROR MESSAGE

\src\Controller\LoginLinkedinController.php (line 76)

object(stdClass) {  
error\_description =\> 'missing required parameters, includes an invalid parameter value, parameter more than once. : Unable to retrieve access token : appId or redirect uri does not match authorization code or authorization code expired’  
error =\> ‘invalid\_request’  
}

---

<div class="post-metadata">

**Author:** ![littleylv](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/littleylv/32/494_2.png) [@littleylv](https://discourse.cakephp.org/u/littleylv)\
**Post date:** [June 23, 2017, 9:31am UTC](https://discourse.cakephp.org/t/problem-to-consume-linkedin-api/2770/2 "2017-06-23T09:31:19Z")

</div>

According to [https://developer.linkedin.com/docs/oauth2](https://developer.linkedin.com/docs/oauth2) section “Step 3 — Exchange Authorization Code for an Access Token”:

> This is done by making the following “x-www-form-urlencoded” HTTP POST request:

> POST [https://www.linkedin.com/oauth/v2/accessToken](https://www.linkedin.com/oauth/v2/accessToken)

You should use `$response = $http->post('https://www.linkedin.com/uas/oauth2/accessToken', $params);`

---

<div class="post-metadata">

**Author:** ![Marcelo](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Marcelo](https://discourse.cakephp.org/u/Marcelo)\
**Post date:** [June 23, 2017, 9:01pm UTC](https://discourse.cakephp.org/t/problem-to-consume-linkedin-api/2770/3 "2017-06-23T21:01:17Z")

</div>

Hello littleylv, thanks a lot for returning my question

Now, when I try to get the user information (firstName,lastName,emailAddress), the APP is returning other error message

THERE IS MY CODE

$http = new Client();  
$response = $http-\>post(‘[https://www.linkedin.com/uas/oauth2/accessToken](https://www.linkedin.com/uas/oauth2/accessToken)’, $params);  
$token = json\_decode($response-\>body);

```
        $user_linkedin = $this->_fetchLinkedin('/v1/people/~:(firstName,lastName,emailAddress)', $token->access_token);
        
        debug($user_linkedin);

```

THERE IS AN ERROR PROMPT

\src\Controller\LoginLinkedinController.php (line 78)

object(stdClass) {  
errorCode =\> (int) 0  
message =\> 'Unknown authentication scheme’  
requestId =\> '2PK898JSK5’  
status =\> (int) 401  
timestamp =\> (float) 1498251361191  
}

I excpected when i debug this " debug($user\_linkedin);" who user information were exhibited
