Skip to content
This repository has been archived by the owner on Feb 26, 2018. It is now read-only.

Commit

Permalink
Update facade name in documentation to avoid conflict with OAuth exte…
Browse files Browse the repository at this point in the history
…nsion
  • Loading branch information
adamwathan committed Sep 13, 2015
1 parent 03a2cca commit 3a420fa
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ Eloquent OAuth is a package for Laravel 5 designed to make authentication agains
```php
// Redirect to Facebook for authorization
Route::get('facebook/authorize', function() {
return OAuth::authorize('facebook');
return SocialAuth::authorize('facebook');
});

// Facebook redirects here after authorization
Route::get('facebook/login', function() {

// Automatically log in existing users
// or create a new user if necessary.
OAuth::login('facebook');
SocialAuth::login('facebook');

// Current user is now available via Auth facade
$user = Auth::user();
Expand Down Expand Up @@ -66,7 +66,7 @@ Add the facade to the `aliases` array in `config/app.php`:
```php
'aliases' => [
// ...
'OAuth' => 'AdamWathan\EloquentOAuth\Facades\OAuth',
'SocialAuth' => 'AdamWathan\EloquentOAuth\Facades\OAuth',
// ...
]
```
Expand Down Expand Up @@ -112,19 +112,19 @@ Authentication against an OAuth provider is a multi-step process, but I have tri

First you will need to define the authorization route. This is the route that your "Login" button will point to, and this route redirects the user to the provider's domain to authorize your app. After authorization, the provider will redirect the user back to your second route, which handles the rest of the authentication process.

To authorize the user, simply return the `OAuth::authorize()` method directly from the route.
To authorize the user, simply return the `SocialAuth::authorize()` method directly from the route.

```php
Route::get('facebook/authorize', function() {
return OAuth::authorize('facebook');
return SocialAuth::authorize('facebook');
});
```

### Authenticating within your app

Next you need to define a route for authenticating against your app with the details returned by the provider.

For basic cases, you can simply call `OAuth::login()` with the provider name you are authenticating with. If the user
For basic cases, you can simply call `SocialAuth::login()` with the provider name you are authenticating with. If the user
rejected your application, this method will throw an `ApplicationRejectedException` which you can catch and handle
as necessary.

Expand All @@ -140,7 +140,7 @@ use SocialNorm\Exceptions\InvalidAuthorizationCodeException;

Route::get('facebook/login', function() {
try {
OAuth::login('facebook');
SocialAuth::login('facebook');
} catch (ApplicationRejectedException $e) {
// User rejected application
} catch (InvalidAuthorizationCodeException $e) {
Expand All @@ -167,7 +167,7 @@ object that contains basic information from the OAuth provider, including:
- Access Token

```php
OAuth::login('facebook', function($user, $details) {
SocialAuth::login('facebook', function($user, $details) {
$user->nickname = $details->nickname;
$user->name = $details->fullName;
$user->profile_image = $details->avatar;
Expand Down Expand Up @@ -197,10 +197,10 @@ But, each provider offers its own sets of additional data. If you need to access
> Note: By increasing the scope you will be asking the user to grant access to additional information. They will be informed of the scopes you're requesting. If you ask for too much unnecessary data, they may refuse. So exercise restraint when requesting additional scopes.
2. Now where you do your `OAuth::login`, store the to your `$user` object by accessing the `$details->raw()['KEY']` data:
2. Now where you do your `SocialAuth::login`, store the to your `$user` object by accessing the `$details->raw()['KEY']` data:

```php
OAuth::login('facebook', function($user, $details) (
SocialAuth::login('facebook', function($user, $details) (
$user->gender = $details->raw()['gender'];
$user->save();
});
Expand Down

0 comments on commit 3a420fa

Please sign in to comment.