summaryrefslogtreecommitdiff
path: root/vendor/league/oauth2-client/src/Provider/LinkedIn.php
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2019-11-17 20:45:02 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2019-11-17 20:45:02 +0100
commit8df3db566a3a937b45ebf11adb90d265e6f5e2d4 (patch)
tree4d541098d751d5a9acf8c12f6fb9f308ace066ac /vendor/league/oauth2-client/src/Provider/LinkedIn.php
downloadflyspray-8df3db566a3a937b45ebf11adb90d265e6f5e2d4.tar.xz
initial checking of customized version 1.0rc9
Diffstat (limited to 'vendor/league/oauth2-client/src/Provider/LinkedIn.php')
-rw-r--r--vendor/league/oauth2-client/src/Provider/LinkedIn.php76
1 files changed, 76 insertions, 0 deletions
diff --git a/vendor/league/oauth2-client/src/Provider/LinkedIn.php b/vendor/league/oauth2-client/src/Provider/LinkedIn.php
new file mode 100644
index 0000000..c790ddf
--- /dev/null
+++ b/vendor/league/oauth2-client/src/Provider/LinkedIn.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace League\OAuth2\Client\Provider;
+
+use League\OAuth2\Client\Entity\User;
+use League\OAuth2\Client\Token\AccessToken;
+
+class LinkedIn extends AbstractProvider
+{
+ public $scopes = [];
+ public $scopeSeparator = ' ';
+ public $responseType = 'json';
+ public $authorizationHeader = 'Bearer';
+ public $fields = [
+ 'id', 'email-address', 'first-name', 'last-name', 'headline',
+ 'location', 'industry', 'picture-url', 'public-profile-url',
+ ];
+
+ public function urlAuthorize()
+ {
+ return 'https://www.linkedin.com/uas/oauth2/authorization';
+ }
+
+ public function urlAccessToken()
+ {
+ return 'https://www.linkedin.com/uas/oauth2/accessToken';
+ }
+
+ public function urlUserDetails(AccessToken $token)
+ {
+ $fields = implode(',', $this->fields);
+ return 'https://api.linkedin.com/v1/people/~:(' . $fields . ')?format=json';
+ }
+
+ public function userDetails($response, AccessToken $token)
+ {
+ $user = new User();
+
+ $email = (isset($response->emailAddress)) ? $response->emailAddress : null;
+ $location = (isset($response->location->name)) ? $response->location->name : null;
+ $description = (isset($response->headline)) ? $response->headline : null;
+ $pictureUrl = (isset($response->pictureUrl)) ? $response->pictureUrl : null;
+ $publicProfileUrl = (isset($response->publicProfileUrl)) ? $response->publicProfileUrl : null;
+
+ $user->exchangeArray([
+ 'uid' => $response->id,
+ 'name' => $response->firstName.' '.$response->lastName,
+ 'firstname' => $response->firstName,
+ 'lastname' => $response->lastName,
+ 'email' => $email,
+ 'location' => $location,
+ 'description' => $description,
+ 'imageurl' => $pictureUrl,
+ 'urls' => $publicProfileUrl,
+ ]);
+
+ return $user;
+ }
+
+ public function userUid($response, AccessToken $token)
+ {
+ return $response->id;
+ }
+
+ public function userEmail($response, AccessToken $token)
+ {
+ return isset($response->emailAddress) && $response->emailAddress
+ ? $response->emailAddress
+ : null;
+ }
+
+ public function userScreenName($response, AccessToken $token)
+ {
+ return [$response->firstName, $response->lastName];
+ }
+}