commit
32c1d8480a
|
@ -5,6 +5,9 @@ This library makes it stupidly simple to integrate your application with OAuth 2
|
|||
* Facebook
|
||||
* Github
|
||||
* Google
|
||||
* Instagram
|
||||
* LinkedIn
|
||||
* Microsoft
|
||||
|
||||
Adding support for other providers is trivial.
|
||||
|
||||
|
@ -62,5 +65,7 @@ if ( ! isset($_GET['code'])) {
|
|||
| **Github** | string | string | string | null | null | string | null | null | null | array (Github, [personal])|
|
||||
| **Google** | string | string | string | string | string | string | null | null | string | null |
|
||||
| **Instagram** | string | string | string | null | null | null | null | string | string | null |
|
||||
| **LinkedIn** | string | null | string | null | null | string | string | string | string | string |
|
||||
| **Microsoft** | string | null | string | string | string | string | null | null | string | string |
|
||||
|
||||
**Notes**: Providers which return URLs sometimes include additional URLs if the user has provided them. These have been wrapped in []
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace League\OAuth2\Client\Provider;
|
||||
|
||||
class Linkedin extends IdentityProvider
|
||||
{
|
||||
public $scopes = array('r_basicprofile r_emailaddress r_contactinfo');
|
||||
public $responseType = 'json';
|
||||
public $fields = array('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(\League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
return 'https://api.linkedin.com/v1/people/~:('.implode(",", $this->fields).')?format=json&oauth2_access_token='.$token;
|
||||
}
|
||||
|
||||
public function userDetails($response, \League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
$user = new User;
|
||||
|
||||
$user->uid = $response->id;
|
||||
$user->name = $response->firstName.' '.$response->lastName;
|
||||
$user->firstName = $response->firstName;
|
||||
$user->lastName = $response->lastName;
|
||||
$user->email = isset($response->emailAddress) ? $response->emailAddress : null;
|
||||
$user->location = isset($response->location->name) ? $response->location->name : null;
|
||||
$user->description = isset($response->headline) ? $response->headline : null;
|
||||
$user->imageUrl = $response->pictureUrl;
|
||||
$user->urls = $response->publicProfileUrl;
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace League\OAuth2\Client\Provider;
|
||||
|
||||
class Microsoft extends IdentityProvider
|
||||
{
|
||||
public $scopes = array('wl.basic', 'wl.emails');
|
||||
public $responseType = 'json';
|
||||
|
||||
public function urlAuthorize()
|
||||
{
|
||||
return 'https://oauth.live.com/authorize';
|
||||
}
|
||||
|
||||
public function urlAccessToken()
|
||||
{
|
||||
return 'https://oauth.live.com/token';
|
||||
}
|
||||
|
||||
public function urlUserDetails(\League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
return 'https://apis.live.net/v5.0/me?access_token='.$token;
|
||||
}
|
||||
|
||||
public function userDetails($response, \League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
$imageHeaders = get_headers('https://apis.live.net/v5.0/'.$response->id.'/picture', 1);
|
||||
|
||||
$user = new User;
|
||||
|
||||
$user->uid = $response->id;
|
||||
$user->name = $response->name;
|
||||
$user->firstName = $response->first_name;
|
||||
$user->lastName = $response->last_name;
|
||||
$user->email = isset($response->emails->preferred) ? $response->emails->preferred : null;
|
||||
$user->imageUrl = $imageHeaders['Location'];
|
||||
$user->urls = $response->link.'/cid-'.$response->id;
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue