index : flyspray | |
Archlinux32 customized Flyspray installation | gitolite user |
summaryrefslogtreecommitdiff |
author | Andreas Baumann <mail@andreasbaumann.cc> | 2020-02-01 09:05:48 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2020-02-01 09:05:48 +0100 |
commit | 6854cb3f4d8219cf1829e32122eb2502a916eae9 (patch) | |
tree | 350feb504587d932e02837a1442b059759927646 /vendor/league/oauth2-client/src/Provider/Microsoft.php |
-rw-r--r-- | vendor/league/oauth2-client/src/Provider/Microsoft.php | 69 |
diff --git a/vendor/league/oauth2-client/src/Provider/Microsoft.php b/vendor/league/oauth2-client/src/Provider/Microsoft.php new file mode 100644 index 0000000..d0ed12e --- /dev/null +++ b/vendor/league/oauth2-client/src/Provider/Microsoft.php @@ -0,0 +1,69 @@ +<?php + +namespace League\OAuth2\Client\Provider; + +use League\OAuth2\Client\Entity\User; +use League\OAuth2\Client\Token\AccessToken; + +class Microsoft extends AbstractProvider +{ + public $scopes = ['wl.basic', 'wl.emails']; + public $responseType = 'json'; + + public function urlAuthorize() + { + return 'https://login.live.com/oauth20_authorize.srf'; + } + + public function urlAccessToken() + { + return 'https://login.live.com/oauth20_token.srf'; + } + + public function urlUserDetails(AccessToken $token) + { + return 'https://apis.live.net/v5.0/me?access_token='.$token; + } + + public function userDetails($response, AccessToken $token) + { + $client = $this->getHttpClient(); + $client->setBaseUrl('https://apis.live.net/v5.0/'.$response->id.'/picture'); + $request = $client->get()->send(); + $info = $request->getInfo(); + $imageUrl = $info['url']; + + $user = new User(); + + $email = (isset($response->emails->preferred)) ? $response->emails->preferred : null; + + $user->exchangeArray([ + 'uid' => $response->id, + 'name' => $response->name, + 'firstname' => $response->first_name, + 'lastname' => $response->last_name, + 'email' => $email, + 'imageurl' => $imageUrl, + 'urls' => $response->link.'/cid-'.$response->id, + ]); + + return $user; + } + + public function userUid($response, AccessToken $token) + { + return $response->id; + } + + public function userEmail($response, AccessToken $token) + { + return isset($response->emails->preferred) && $response->emails->preferred + ? $response->emails->preferred + : null; + } + + public function userScreenName($response, AccessToken $token) + { + return [$response->first_name, $response->last_name]; + } +} |