- ユーザがログインしており、Auth にレコードが見つかった場合は、If user is logged in and record found in auth then try connecting additional account (save its data into auth table).
- If user is guest and record not found in auth then create new user and make a record in auth table. Then log in.
Although, all clients are different they shares same basic interface [[yii\authclient\ClientInterface]],
which governs common API.
Each client has some descriptive data, which can be used for different purposes:
-`id` - unique client id, which separates it from other clients, it could be used in URLs, logs etc.
-`name` - external auth provider name, which this client is match too. Different auth clients
can share the same name, if they refer to the same external auth provider.
For example: clients for Google OpenID and Google OAuth have same name "google".
This attribute can be used inside the database, CSS styles and so on.
-`title` - user friendly name for the external auth provider, it is used to present auth client
at the view layer.
Each auth client has different auth flow, but all of them supports `getUserAttributes()` method,
which can be invoked if authentication was successful.
This method allows you to get information about external user account, such as ID, email address,
full name, preferred language etc.
Defining list of attributes, which external auth provider should return, depends on client type:
-[[yii\authclient\OpenId]]: combination of `requiredAttributes` and `optionalAttributes`.
-[[yii\authclient\OAuth1]] and [[yii\authclient\OAuth2]]: field `scope`, note that different
providers use different formats for the scope.
### Getting additional data via extra API calls
Both [[yii\authclient\OAuth1]] and [[yii\authclient\OAuth2]] provide method `api()`, which
can be used to access external auth provider REST API. However this method is very basic and
it may be not enough to access full external API functionality. This method is mainly used to
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: