yii\authclient\clients\LinkedIn - Yii2 类参考手册

Class yii\authclient\clients\LinkedIn

Inheritanceyii\authclient\clients\LinkedIn » yii\authclient\OAuth2 » yii\authclient\BaseOAuth » yii\authclient\BaseClient » yii\base\Component » yii\base\BaseObject
Implementsyii\authclient\ClientInterface, yii\base\Configurable
Available since version2.0

LinkedIn allows authentication via LinkedIn OAuth.

In order to use linkedIn OAuth you must register your application at https://www.linkedin.com/secure/developer.

Example application configuration:

'components' => [
    'authClientCollection' => [
        'class' => 'yii\authclient\Collection',
        'clients' => [
            'linkedin' => [
                'class' => 'yii\authclient\clients\LinkedIn',
                'clientId' => 'linkedin_client_id',
                'clientSecret' => 'linkedin_client_secret',
            ],
        ],
    ]
    // ...
]

请参阅:

Public Properties

隐藏继承的属性 Hide inherited properties

属性Property类型 Type简介 Description定义在 Defined By
$accessToken array|yii\authclient\OAuthToken Access token or its configuration. yii\authclient\BaseOAuth
$apiBaseUrl string API base URL. yii\authclient\clients\LinkedIn
$attributeNames array List of attribute names, which should be requested from API to initialize user attributes. yii\authclient\clients\LinkedIn
$authUrl string Authorize URL. yii\authclient\clients\LinkedIn
$autoRefreshAccessToken boolean Whether to automatically perform 'refresh access token' request on expired access token. yii\authclient\BaseOAuth
$behaviors yii\base\Behavior[] List of behaviors attached to this component yii\base\Component
$clientId string OAuth client ID. yii\authclient\OAuth2
$clientSecret string OAuth client secret. yii\authclient\OAuth2
$httpClient yii\httpclient\Client Internal HTTP client. yii\authclient\BaseClient
$id string Service id. yii\authclient\BaseClient
$name string Service name. yii\authclient\BaseClient
$normalizeUserAttributeMap array Normalize user attribute map. yii\authclient\BaseClient
$requestOptions array HTTP request options. yii\authclient\BaseClient
$returnUrl string Return URL yii\authclient\BaseOAuth
$scope string Auth request scope. yii\authclient\BaseOAuth
$signatureMethod array|yii\authclient\signature\BaseMethod Signature method instance or its array configuration. yii\authclient\BaseOAuth
$stateStorage yii\authclient\StateStorageInterface Stage storage. yii\authclient\BaseClient
$title string Service title. yii\authclient\BaseClient
$tokenUrl string Token request URL endpoint. yii\authclient\clients\LinkedIn
$userAttributes array List of user attributes yii\authclient\BaseClient
$validateAuthState boolean Whether to use and validate auth 'state' parameter in authentication flow. yii\authclient\OAuth2
$version string Protocol version. yii\authclient\OAuth2
$viewOptions array View options in format: optionName => optionValue yii\authclient\BaseClient

Public Methods

隐藏继承的方法 Hide inherited methods

方法 Method简介 Description定义在 Defined By
__call() Calls the named method which is not a class method. yii\base\Component
__clone() This method is called after the object is created by cloning an existing one. yii\base\Component
__construct() Constructor. yii\base\BaseObject
__get() Returns the value of a component property. yii\base\Component
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Component
__set() Sets the value of a component property. yii\base\Component
__unset() Sets a component property to be null. yii\base\Component
api() Performs request to the OAuth API returning response data. yii\authclient\BaseOAuth
applyAccessTokenToRequest() Applies access token to the HTTP request instance. yii\authclient\clients\LinkedIn
attachBehavior() Attaches a behavior to this component. yii\base\Component
attachBehaviors() Attaches a list of behaviors to the component. yii\base\Component
authenticateClient() Authenticate OAuth client directly at the provider without third party (user) involved, using 'client_credentials' grant type. yii\authclient\OAuth2
authenticateUser() Authenticates user directly by 'username/password' pair, using 'password' grant type. yii\authclient\OAuth2
authenticateUserJwt() Authenticates user directly using JSON Web Token (JWT). yii\authclient\OAuth2
beforeApiRequestSend() Handles yii\httpclient\Request::EVENT_BEFORE_SEND event. yii\authclient\BaseOAuth
behaviors() Returns a list of behaviors that this component should behave as. yii\base\Component
buildAuthUrl() Composes user authorization URL. yii\authclient\OAuth2
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Component
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Component
className() Returns the fully qualified name of this class. yii\base\BaseObject
createApiRequest() Creates an HTTP request for the API call. yii\authclient\BaseOAuth
createRequest() Creates HTTP request instance. yii\authclient\BaseClient
detachBehavior() Detaches a behavior from the component. yii\base\Component
detachBehaviors() Detaches all behaviors from the component. yii\base\Component
ensureBehaviors() Makes sure that the behaviors declared in behaviors() are attached to this component. yii\base\Component
fetchAccessToken() Fetches access token from authorization code. yii\authclient\OAuth2
getAccessToken() yii\authclient\BaseOAuth
getBehavior() Returns the named behavior object. yii\base\Component
getBehaviors() Returns all behaviors attached to this component. yii\base\Component
getHttpClient() Returns HTTP client. yii\authclient\BaseClient
getId() yii\authclient\BaseClient
getName() yii\authclient\BaseClient
getNormalizeUserAttributeMap() yii\authclient\BaseClient
getRequestOptions() yii\authclient\BaseClient
getReturnUrl() yii\authclient\BaseOAuth
getSignatureMethod() yii\authclient\BaseOAuth
getStateStorage() yii\authclient\BaseClient
getTitle() yii\authclient\BaseClient
getUserAttributes() yii\authclient\BaseClient
getViewOptions() yii\authclient\BaseClient
hasEventHandlers() Returns a value indicating whether there is any handler attached to the named event. yii\base\Component
hasMethod() Returns a value indicating whether a method is defined. yii\base\Component
hasProperty() Returns a value indicating whether a property is defined for this component. yii\base\Component
init() Initializes the object. yii\authclient\clients\LinkedIn
off() Detaches an existing event handler from this component. yii\base\Component
on() Attaches an event handler to an event. yii\base\Component
refreshAccessToken() Gets new auth token to replace expired one. yii\authclient\OAuth2
setAccessToken() Sets access token to be used. yii\authclient\BaseOAuth
setHttpClient() Sets HTTP client to be used. yii\authclient\BaseClient
setId() yii\authclient\BaseClient
setName() yii\authclient\BaseClient
setNormalizeUserAttributeMap() yii\authclient\BaseClient
setRequestOptions() yii\authclient\BaseClient
setReturnUrl() yii\authclient\BaseOAuth
setSignatureMethod() Set signature method to be used. yii\authclient\BaseOAuth
setStateStorage() yii\authclient\BaseClient
setTitle() yii\authclient\BaseClient
setUserAttributes() yii\authclient\BaseClient
setViewOptions() yii\authclient\BaseClient
trigger() Triggers an event. yii\base\Component

Protected Methods

隐藏继承的方法 Hide inherited methods

方法 Method简介 Description定义在 Defined By
applyClientCredentialsToRequest() Applies client credentials (e.g. $clientId and $clientSecret) to the HTTP request instance. yii\authclient\OAuth2
composeUrl() Composes URL from base URL and GET params. yii\authclient\BaseOAuth
createHttpClient() Creates HTTP client instance from reference or configuration. yii\authclient\BaseClient
createSignatureMethod() Creates signature method instance from its configuration. yii\authclient\BaseOAuth
createToken() Creates token from its configuration. yii\authclient\OAuth2
defaultName() Generates service name. yii\authclient\clients\LinkedIn
defaultNormalizeUserAttributeMap() Returns the default $normalizeUserAttributeMap value. yii\authclient\clients\LinkedIn
defaultRequestOptions() Returns default HTTP request options. yii\authclient\BaseClient
defaultReturnUrl() Composes default $returnUrl value. yii\authclient\OAuth2
defaultTitle() Generates service title. yii\authclient\clients\LinkedIn
defaultViewOptions() Returns the default $viewOptions value. yii\authclient\BaseClient
generateAuthState() Generates the auth state value. yii\authclient\OAuth2
getState() Returns persistent state value. yii\authclient\BaseClient
getStateKeyPrefix() Returns session key prefix, which is used to store internal states. yii\authclient\BaseClient
initUserAttributes() Initializes authenticated user attributes. yii\authclient\clients\LinkedIn
normalizeUserAttributes() Normalize given user attributes according to $normalizeUserAttributeMap. yii\authclient\BaseClient
removeState() Removes persistent state value. yii\authclient\BaseClient
restoreAccessToken() Restores access token. yii\authclient\BaseOAuth
saveAccessToken() Saves token as persistent state. yii\authclient\BaseOAuth
sendRequest() Sends the given HTTP request, returning response data. yii\authclient\BaseOAuth
setState() Sets persistent state. yii\authclient\BaseClient

属性详情 Property Details

$apiBaseUrl public property

API base URL. This field will be used as yii\httpclient\Client::$baseUrl value of $httpClient. Note: changing this property will take no effect after $httpClient is instantiated.

public string $apiBaseUrl 'https://api.linkedin.com/v1'
$attributeNames public property (available since version 2.0.4)

List of attribute names, which should be requested from API to initialize user attributes.

public array $attributeNames = ['id''email-address''first-name''last-name''public-profile-url']
$authUrl public property

Authorize URL.

public string $authUrl 'https://www.linkedin.com/oauth/v2/authorization'
$tokenUrl public property

Token request URL endpoint.

public string $tokenUrl 'https://www.linkedin.com/oauth/v2/accessToken'

方法详情 Method Details

applyAccessTokenToRequest() public method

Applies access token to the HTTP request instance.

public void applyAccessTokenToRequest ( $request, $accessToken )
$request yii\httpclient\Request

HTTP request instance.

$accessToken yii\authclient\OAuthToken

Access token instance.

defaultName() protected method

Generates service name.

protected string defaultName ( )
return string

Service name.

defaultNormalizeUserAttributeMap() protected method

Returns the default $normalizeUserAttributeMap value.

Particular client may override this method in order to provide specific default map.

protected array defaultNormalizeUserAttributeMap ( )
return array

Normalize attribute map.

defaultTitle() protected method

Generates service title.

protected string defaultTitle ( )
return string

Service title.

init() public method

Initializes the object.

This method is invoked at the end of the constructor after the object is initialized with the given configuration.

public void init ( )
initUserAttributes() protected method

Initializes authenticated user attributes.

protected array initUserAttributes ( )
return array

Auth user attributes.