You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package makes it stupidly simple to integrate your application with OAuth 2.0 identity providers.
9
-
10
-
Everyone is used to seeing those "Connect with Facebook/Google/etc" buttons around the Internet and social network
11
-
integration is an important feature of most web-apps these days. Many of these sites use an Authentication and Authorization standard called OAuth 2.0.
12
-
13
-
It will work with any OAuth 2.0 provider (be it an OAuth 2.0 Server for your own API or Facebook) and provides support
14
-
for popular systems out of the box. This package abstracts out some of the subtle but important differences between various providers, handles access tokens and refresh tokens, and allows you easy access to profile information on these other sites.
9
+
This package provides Google OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).
15
10
16
11
This package is compliant with [PSR-1][], [PSR-2][] and [PSR-4][]. If you notice compliance oversights, please send
17
12
a patch via pull request.
@@ -30,16 +25,25 @@ The following versions of PHP are supported.
30
25
* PHP 5.6
31
26
* HHVM
32
27
28
+
## Installation
29
+
30
+
To install, use composer:
31
+
32
+
```
33
+
composer require league/oauth2-google
34
+
```
35
+
33
36
## Usage
34
37
35
38
### Authorization Code Flow
36
39
37
40
```php
38
-
$provider = new League\OAuth2\Client\Provider\<ProviderName>([
If you are working with an oauth2 service not supported out-of-the-box or by an existing package, it is quite simple to
148
-
implement your own. Simply extend `League\OAuth2\Client\Provider\AbstractProvider` and implement the required abstract
149
-
methods:
150
-
151
-
```php
152
-
abstract public function urlAuthorize();
153
-
abstract public function urlAccessToken();
154
-
abstract public function urlUserDetails(\League\OAuth2\Client\Token\AccessToken $token);
155
-
abstract public function userDetails($response, \League\OAuth2\Client\Token\AccessToken $token);
156
-
```
157
-
158
-
Each of these abstract methods contain a docblock defining their expectations and typical behaviour. Once you have
159
-
extended this class, you can simply follow the example above using your new `Provider`.
160
-
161
-
#### Custom account identifiers in access token responses
162
-
163
-
Some OAuth2 Server implementations include a field in their access token response defining some identifier
164
-
for the user account that just requested the access token. In many cases this field, if present, is called "uid", but
165
-
some providers define custom identifiers in their response. If your provider uses a nonstandard name for the "uid" field,
166
-
when extending the AbstractProvider, in your new class, define a property `public $uidKey` and set it equal to whatever
167
-
your provider uses as its key. For example, Battle.net uses `accountId` as the key for the identifier field, so in that
168
-
provider you would add a property:
169
-
170
-
```php
171
-
public $uidKey = 'accountId';
172
-
```
173
-
174
-
### Client Packages
175
-
176
-
Some developers use this library as a base for their own PHP API wrappers, and that seems like a really great idea. It might make it slightly tricky to integrate their provider with an existing generic "OAuth 2.0 All the Things" login system, but it does make working with them easier.
177
-
178
-
-[Sniply](https://github.com/younes0/sniply)
179
-
180
-
## Install
181
-
182
-
Via Composer
183
-
184
-
```bash
185
-
$ composer require league/oauth2-client
186
-
```
187
-
188
109
## Testing
189
110
190
111
```bash
@@ -193,19 +114,15 @@ $ ./vendor/bin/phpunit
193
114
194
115
## Contributing
195
116
196
-
Please see [CONTRIBUTING](https://github.com/thephpleague/oauth2-client/blob/master/CONTRIBUTING.md) for details.
117
+
Please see [CONTRIBUTING](https://github.com/thephpleague/oauth2-google/blob/master/CONTRIBUTING.md) for details.
0 commit comments