public function callback()
    {
        //Salesforce sends us an authorization code as part of the Web Server OAuth Authentication Flow
        $code = $this->input->get('code');

        $stateOptions = json_decode(urldecode($this->input->get('state')), true);

        //Store instance URL
        $loginURL = $stateOptions['loginUrl'];

        // Store user options so they can be used later
        $this->stateRepo->put($stateOptions);

        $tokenURL = $loginURL.'/services/oauth2/token';

        $jsonResponse = $this->httpClient->request('post', $tokenURL, [
            'form_params' => [
                'code'          => $code,
                'grant_type'    => 'authorization_code',
                'client_id'     => $this->credentials['consumerKey'],
                'client_secret' => $this->credentials['consumerSecret'],
                'redirect_uri'  => $this->credentials['callbackURI'],
            ],
        ]);

        // Response returns an json of access_token, instance_url, id, issued_at, and signature.
        $response = json_decode($jsonResponse->getBody(), true);
        $this->handleAuthenticationErrors($response);

        // Encrypt token and store token in storage.
        $this->tokenRepo->put($response);

        if (isset($response['refresh_token'])) {
            $this->refreshTokenRepo->put($response['refresh_token']);
        }

        $this->storeVersion();
        $this->storeResources();

        // Return settings
        return $stateOptions;
    }
public function callback()
    {
        //Salesforce sends us an authorization code as part of the Web Server OAuth Authentication Flow
        $code = $this->input->get('code');

        $stateOptions = json_decode(urldecode($this->input->get('state')), true);

        //Store instance URL
        $loginURL = $stateOptions['loginUrl'];

        // Store user options so they can be used later
        $this->stateRepo->put($stateOptions);

        $tokenURL = $loginURL.'/services/oauth2/token';

        $jsonResponse = $this->httpClient->request('post', $tokenURL, [
            'form_params' => [
                'code'          => $code,
                'grant_type'    => 'authorization_code',
                'client_id'     => $this->credentials['consumerKey'],
                'client_secret' => $this->credentials['consumerSecret'],
                'redirect_uri'  => $this->credentials['callbackURI'],
            ],
        ]);

        // Response returns an json of access_token, instance_url, id, issued_at, and signature.
        $response = json_decode($jsonResponse->getBody(), true);
        $this->handleAuthenticationErrors($response);

        // Encrypt token and store token in storage.
        $this->tokenRepo->put($response);

        if (isset($response['refresh_token'])) {
            $this->refreshTokenRepo->put($response['refresh_token']);
        }

        $this->storeVersion();
        $this->storeResources();

        // Return settings
        return $stateOptions;
    }
public function callback ( ) { //Salesforce sends us an authorization code as part of the Web Server OAuth Authentication Flow $ code = $ this -> input -> get ( 'code' ) ; $ stateOptions = json_decode ( urldecode ( $ this -> input -> get ( 'state' ) ) , true ) ; //Store instance URL $ loginURL = $ stateOptions [ 'loginUrl' ] ; // Store user options so they can be used later $ this -> stateRepo -> put ( $ stateOptions ) ; $ tokenURL = $ loginURL . '/services/oauth2/token' ; $ jsonResponse = $ this -> httpClient -> request ( 'post' , $ tokenURL , [ 'form_params' => [ 'code' => $ code , 'grant_type' => 'authorization_code' , 'client_id' => $ this -> credentials [ 'consumerKey' ] , 'client_secret' => $ this -> credentials [ 'consumerSecret' ] , 'redirect_uri' => $ this -> credentials [ 'callbackURI' ] , ] , ] ) ; // Response returns an json of access_token, instance_url, id, issued_at, and signature. $ response = json_decode ( $ jsonResponse -> getBody ( ) , true ) ; $ this -> handleAuthenticationErrors ( $ response ) ; // Encrypt token and store token in storage. $ this -> tokenRepo -> put ( $ response ) ; if ( isset ( $ response [ 'refresh_token' ] ) ) { $ this -> refreshTokenRepo -> put ( $ response [ 'refresh_token' ] ) ; } $ this -> storeVersion ( ) ; $ this -> storeResources ( ) ; // Return settings return $ stateOptions ; }
When settings up your callback route, you will need to call this method to
acquire an authorization token. This token will be used for the API requests.

@return RedirectInterface
When settings up your callback route you will need to call this method to acquire an authorization token . This token will be used for the API requests .