protected function _getProfile($providerName, ServerRequest $request)
    {
        try {
            $provider = $this->_getService($request)->getProvider($providerName);
            $accessToken = $provider->getAccessTokenByRequestParameters($request->getQueryParams());
            $identity = $provider->getIdentity($accessToken);
        } catch (SocialConnectException $e) {
            $this->_error = 'provider_failure';

            if ($this->getConfig('logErrors')) {
                Log::error($this->_getLogMessage($request, $e));
            }

            return null;
        }

        $profile = $this->_profileModel->find()
            ->where([
                $this->_profileModel->aliasField('provider') => $providerName,
                $this->_profileModel->aliasField('identifier') => $identity->id,
            ])
            ->first();

        $profile = $this->_patchProfile(
            $providerName,
            $identity,
            $accessToken,
            $profile ?: null
        );
        if ($profile->isDirty()) {
            $this->_saveProfile($profile);
        }

        return $profile;
    }
protected function _getProfile($providerName, ServerRequest $request)
    {
        try {
            $provider = $this->_getService($request)->getProvider($providerName);
            $accessToken = $provider->getAccessTokenByRequestParameters($request->getQueryParams());
            $identity = $provider->getIdentity($accessToken);
        } catch (SocialConnectException $e) {
            $this->_error = 'provider_failure';

            if ($this->getConfig('logErrors')) {
                Log::error($this->_getLogMessage($request, $e));
            }

            return null;
        }

        $profile = $this->_profileModel->find()
            ->where([
                $this->_profileModel->aliasField('provider') => $providerName,
                $this->_profileModel->aliasField('identifier') => $identity->id,
            ])
            ->first();

        $profile = $this->_patchProfile(
            $providerName,
            $identity,
            $accessToken,
            $profile ?: null
        );
        if ($profile->isDirty()) {
            $this->_saveProfile($profile);
        }

        return $profile;
    }
protected function _getProfile ( $ providerName , ServerRequest $ request ) { try { $ provider = $ this -> _getService ( $ request ) -> getProvider ( $ providerName ) ; $ accessToken = $ provider -> getAccessTokenByRequestParameters ( $ request -> getQueryParams ( ) ) ; $ identity = $ provider -> getIdentity ( $ accessToken ) ; } catch ( SocialConnectException $ e ) { $ this -> _error = 'provider_failure' ; if ( $ this -> getConfig ( 'logErrors' ) ) { Log :: error ( $ this -> _getLogMessage ( $ request , $ e ) ) ; } return null ; } $ profile = $ this -> _profileModel -> find ( ) -> where ( [ $ this -> _profileModel -> aliasField ( 'provider' ) => $ providerName , $ this -> _profileModel -> aliasField ( 'identifier' ) => $ identity -> id , ] ) -> first ( ) ; $ profile = $ this -> _patchProfile ( $ providerName , $ identity , $ accessToken , $ profile ? : null ) ; if ( $ profile -> isDirty ( ) ) { $ this -> _saveProfile ( $ profile ) ; } return $ profile ; }
Get social profile record.

@param string $providerName Provider name.
@param \Cake\Http\ServerRequest $request Request instance.

@return \Cake\Datasource\EntityInterface|null
Get social profile record .