Merge branch 'release/0.1' into develop
commit
b2af8d7f1c
75
README.md
75
README.md
|
@ -1,22 +1,65 @@
|
|||
# OAuth 2.0 Client Library
|
||||
|
||||
This library makes it stupidly simple to integrate your application with OAuth 2.0 identity providers. It has built in support for:
|
||||
|
||||
* Facebook
|
||||
* Github
|
||||
* Google
|
||||
|
||||
### List of identity providers
|
||||
Adding support for other providers is trivial.
|
||||
|
||||
| Provider | uid | nickname | name | first_name | last_name | email | location | description | imageUrl | urls |
|
||||
| :------------- | :----- | :------- | :----- | :--------- | :-------- | :----- | :------- | :---------- | :------- | :--------------------- |
|
||||
| **Blooie** | string | string | string | string | string | string | string | string | string | array (Facebook) |
|
||||
| **Facebook** | string | string | string | string | string | string | string | string | string | array (Facebook) |
|
||||
| **Foursquare** | string | null | string | string | string | string | string | null | string | array (Foursquare) |
|
||||
| **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 | null | string | array ([personal]) |
|
||||
| **Mailchimp** | string | null | null | null | null | null | null | null | null | null |
|
||||
| **Mailru** | string | string | string | string | string | string | null | null | string | null |
|
||||
| **Paypal** | string | string | sting | string | string | string | string | null | null | array (Paypal) |
|
||||
| **Soundcloud** | string | string | string | null | null | null | string | string | string | array ([Myspace], [personal]) |
|
||||
| **Vkontakte** | null | string | string | string | string | null | null | null | string | null |
|
||||
| **Windows Live** | string | string | string | null | null | null | string | null | null | array(Windows Live) |
|
||||
| **Yandex** | string | string | string | string | string | string | string | string | string | null |
|
||||
The library requires PHP 5.3+ and is PSR-0 compatible.
|
||||
|
||||
## Usage
|
||||
|
||||
```php
|
||||
$provider = new \OAuth2\Client\Provider\<provider name>(array(
|
||||
'clientId' => 'XXXXXXXX',
|
||||
'clientSecret' => 'XXXXXXXX',
|
||||
'redirectUri' => 'http://your-registered-redirect-uri/'
|
||||
));
|
||||
|
||||
if ( ! isset($_GET['code'])) {
|
||||
|
||||
// If we don't have an authorization code then get one
|
||||
$provider->authorize();
|
||||
|
||||
} else {
|
||||
|
||||
try {
|
||||
|
||||
// Try to get an access token (using the authorization code grant)
|
||||
$t = $provider->getAccessToken('authorization_code', array('code' => $_GET['code']));
|
||||
|
||||
try {
|
||||
|
||||
// We got an access token, let's now get the user's details
|
||||
$userDetails = $provider->getUserDetails($t);
|
||||
|
||||
foreach ($userDetails as $attribute => $value) {
|
||||
var_dump($attribute, $value) . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
// Failed to get user details
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
// Failed to get access token
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### List of built-in identity providers
|
||||
|
||||
| Provider | uid | nickname | name | first_name | last_name | email | location | description | imageUrl | urls |
|
||||
| :------- | :----- | :------- | :----- | :--------- | :-------- | :----- | :------- | :---------- | :------- | :--- |
|
||||
| **Facebook** | string | string | string | string | string | string | string | string | string | array (Facebook) |
|
||||
| **Github** | string | string | string | null | null | string | null | null | null | array (Github, [personal])|
|
||||
| **Google** | string | string | string | string | string | string | null | null | string | null |
|
||||
|
||||
**Notes**: Providers which return URLs sometimes include additional URLs if the user has provided them. These have been wrapped in []
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "lncd/oauth2-client",
|
||||
"description": "OAuth 2.0 Client Library",
|
||||
"version": "0.0.1",
|
||||
"version": "0.1",
|
||||
"homepage": "https://github.com/lncd/OAuth2-Client",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
|
@ -34,12 +34,6 @@
|
|||
"email": "hello@alexbilbie.com",
|
||||
"homepage": "http://www.alexbilbie.com",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Dan Horrigan",
|
||||
"email": "me@dandoescode.com",
|
||||
"homepage": "http://www.dandoescode.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
|
|
Loading…
Reference in New Issue