Browse Source

'authclient' docs adjusted

tags/2.0.0
Klimov Paul 10 years ago
parent
commit
6ba7b52322
  1. 44
      extensions/authclient/README.md

44
extensions/authclient/README.md

@ -32,7 +32,7 @@ It covers OpenID, OAuth1 and OAuth2 protocols.
You need to setup auth client collection application component:
```
```php
'components' => [
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
@ -53,7 +53,7 @@ You need to setup auth client collection application component:
Then you need to add [[yii\authclient\AuthAction]] to some of your web controllers:
```
```php
class SiteController extends Controller
{
public function actions()
@ -76,7 +76,7 @@ class SiteController extends Controller
You may use [[yii\authclient\widgets\AuthChoice]] to compose auth client selection:
```
```php
<?= yii\authclient\widgets\AuthChoice::widget([
'baseAuthUrl' => ['site/auth']
]) ?>
@ -132,7 +132,8 @@ it may be not enough to access full external API functionality. This method is m
fetch the external user account data.
To use API calls, you need to setup [[yii\authclient\BaseOAuth::apiBaseUrl]] according to the
API specification. Then you can call [[yii\authclient\BaseOAuth::api()]] method:
```
```php
use yii\authclient\OAuth2;
$client = new OAuth2;
@ -164,6 +165,33 @@ Following predefined auth clients are available:
Please, refer to the particular client class documentation for its actual usage.
Customize auth clients
----------------------
All predefined auth clients have a default configuration like `authUrl`, `apiBaseUrl` and so on.
However in some cases you may want to change these values in order to achieve some specific results.
For example: using `yii\authclient\clients\Facebook` you may want the auth window appear in popup display
mode, which is setup via `authUrl`:
```php
'components' => [
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
'clients' => [
'facebook' => [
'class' => 'yii\authclient\clients\Facebook',
// Facebook login form will be displayed in 'popup' mode
'authUrl' => 'https://www.facebook.com/dialog/oauth?display=popup',
'clientId' => 'facebook_client_id',
'clientSecret' => 'facebook_client_secret',
],
],
]
...
]
```
Creating your own auth clients
------------------------------
@ -178,7 +206,7 @@ for your extension:
At this stage you can determine auth client default name, title and view options, declaring
corresponding methods:
```
```php
use yii\authclient\OAuth2;
class MyAuthClient extends OAuth2
@ -211,7 +239,7 @@ All you need is specify auth URL, by redeclaring "authUrl" field.
You may also setup default required and/or optional attributes.
For example:
```
```php
use yii\authclient\OpenId;
class MyAuthClient extends OpenId
@ -239,7 +267,7 @@ You will need to specify:
For example:
```
```php
use yii\authclient\OAuth2;
class MyAuthClient extends OAuth2
@ -273,7 +301,7 @@ You will need to specify:
For example:
```
```php
use yii\authclient\OAuth1;
class MyAuthClient extends OAuth1

Loading…
Cancel
Save