Hybrid_Providers_LinkedIn::loginFinish PHP Method

loginFinish() public method

public loginFinish ( )
    function loginFinish()
    {
        // in case we get oauth_problem=user_refused
        if (isset($_REQUEST['oauth_problem']) && $_REQUEST['oauth_problem'] == "user_refused") {
            throw new Exception("Authentication failed! The user denied your request.", 5);
        }
        $oauth_token = isset($_REQUEST['oauth_token']) ? $_REQUEST['oauth_token'] : null;
        $oauth_verifier = isset($_REQUEST['oauth_verifier']) ? $_REQUEST['oauth_verifier'] : null;
        if (!$oauth_token || !$oauth_verifier) {
            throw new Exception("Authentication failed! {$this->providerId} returned an invalid Token.", 5);
        }
        $response = $this->api->retrieveTokenAccess($oauth_token, $this->token("oauth_token_secret"), $oauth_verifier);
        if (isset($response['success']) && $response['success'] === true) {
            $this->deleteToken("oauth_token");
            $this->deleteToken("oauth_token_secret");
            $this->token("access_token_linkedin", $response['linkedin']);
            $this->token("access_token", $response['linkedin']['oauth_token']);
            $this->token("access_token_secret", $response['linkedin']['oauth_token_secret']);
            // set user as logged in
            $this->setUserConnected();
        } else {
            throw new Exception("Authentication failed! {$this->providerId} returned an invalid Token in response: " . Hybrid_Logger::dumpData($response), 5);
        }
    }