Skip to content

Commit

Permalink
update oauth library for linkedin (#226)
Browse files Browse the repository at this point in the history
* add deployer script

* refactor subdomain processing and add test to it (#205)

* fix/var subs (#215)

* refactor subdomain processing and add test to it (#204)

* refactor subdomain processing and add test to it

* add other envs to deployment

* make config process deep ENV substitution

* fix/var subs (#216)

* refactor subdomain processing and add test to it (#204)

* refactor subdomain processing and add test to it

* add other envs to deployment

* make config process deep ENV substitution

* fix namespace

* update oauth library for linkedin

* update up to a working commit

* fix linkedin call
  • Loading branch information
microstudi committed Sep 9, 2021
1 parent 5f6e1b8 commit 025c533
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 47 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -15,7 +15,7 @@
"jdorn/file-system-cache": "dev-master",
"intervention/image": "~2.0",
"mibe/feedwriter": "~1.0",
"lusitanian/oauth": "^0.8.9",
"lusitanian/oauth": "dev-master#c3b5e51fcf86ebe83023d34744d7da131a9744a5",
"iignatov/lightopenid": "~1.0",
"paypal/adaptivepayments-sdk-php": "*",
"paypal/merchant-sdk-php": "*",
Expand Down
43 changes: 25 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 9 additions & 28 deletions src/Goteo/Library/OAuth/SocialAuth.php
Expand Up @@ -279,7 +279,7 @@ public function authenticateGoogle() {
$this->host . '/login/google'
);

// Instantiate the twitter service using the credentials, http client and storage mechanism for the token
// Instantiate the google service using the credentials, http client and storage mechanism for the token
$googleService = $this->serviceFactory->createService('google', $credentials, $this->storage, array('userinfo_email', 'userinfo_profile'));


Expand Down Expand Up @@ -429,7 +429,7 @@ public function authenticateLinkedin() {
);
// Instantiate the Linkedin service using the credentials, http client and storage mechanism for the token
/** @var $linkedinService Linkedin */
$linkedinService = $this->serviceFactory->createService('linkedin', $credentials, $this->storage, array('r_basicprofile', 'r_emailaddress'));
$linkedinService = $this->serviceFactory->createService('linkedin', $credentials, $this->storage, array('r_liteprofile', 'r_emailaddress'));

if (!empty($_GET['code'])) {
// retrieve the CSRF state parameter
Expand All @@ -439,35 +439,16 @@ public function authenticateLinkedin() {
$token = $linkedinService->requestAccessToken($_GET['code'], $state);

// Send a request with it. Please note that XML is the default format.
$result = json_decode($linkedinService->request('/people/~:(id,first-name,last-name,email-address,summary,public-profile-url,picture-url,headline,interests,location:(name))?format=json'));
//$result = json_decode($linkedinService->request('/people/~:(id,first-name,last-name,email-address,picture-url)?format=json'));
$result = json_decode($linkedinService->request('me?projection=(id,localizedLastName,localizedFirstName,profilePicture(displayImage~digitalmediaAsset:playableStreams))'), true);
$this->tokens['linkedin']['token'] = $result["id"];

$this->tokens['linkedin']['token'] = $result->id ? $result->id : $result->emailAddress;
$this->user_data['name'] = trim($result["localizedFirstName"] . ' ' . $result["localizedLastName"]);

$this->user_data['name'] = trim($result->firstName . ' ' . $result->lastName);
if($result->emailAddress) $this->user_data['email'] = $result->emailAddress;

if($result->publicProfileUrl) {
//linkedin link
$this->user_data['linkedin'] = $result->publicProfileUrl;
//username from url
$this->user_data['username'] = basename($this->user_data['linkedin']);
if($result["profilePicture"]["displayImage~"]["elements"][0]["identifiers"][0]["identifier"]) {
$this->user_data['avatar'] = $result["profilePicture"]["displayImage~"]["elements"][0]["identifiers"][0]["identifier"];
$this->user_data['avatar_name'] = $result['id'] . '.jpg';
}

if($result->headline) $this->user_data['about'] = $result->headline;
if($result->location->name) $this->user_data['location'] = $result->location->name;
if($result->pictureUrl) {
$this->user_data['avatar'] = $result->pictureUrl;
$this->user_data['avatar_name'] = $this->user_data['username'] . '.jpg';
}
if($result->summary) $this->user_data['website'] = $result->summary;
// if($result->memberUrlResources->memberUrl) {
// foreach($result->memberUrlResources->memberUrl as $url) {
// $this->user_data['website'] .= $url->url . "\n";
// }
// }
//si el usuario tiene especificada su cuenta twitter
// if($result->twitterAccounts->twitterAccount) $this->user_data['twitter'] = 'http://twitter.com/' . current($result->twitterAccounts->twitterAccount->providerAccountName);

// Show some of the resultant data
// echo '<pre>' . print_r($this->user_data, 1) . print_r($result, 1) . '</pre>';die;

Expand Down

0 comments on commit 025c533

Please sign in to comment.