Pocket API authorization loop Setting up a plugin using Pocket API and I'm currently in a authorization loop.

Index template calls the init function. Init function gets requestToken (successfully) and then redirects to Pocket for app authorization (authorizeToken function). After authorization, redirected to callback. 

From here, I need to convert the token to a 'Pocket access token', but when the controlller fires it seems to call the init function before the accessToken function and I end up in an endless loop. 

Can anyone explain why this is happening? Am I going about this the right way?

Index template:

{% extends "_layouts/cp" %}
{% set title = "Pocket Articles"|t %}

{% set offset = craft.request.getParam('offset') %}
{% set start = craft.pocket.init() %}

{% set content %}
    {{ start }}
{% endset %}


Service:

public function init(){
    $token  = $this-&gt;requestToken();
    $auth   = $this-&gt;authorizeToken($token);
    return;
}

public function accessToken($code){
    $url                    = $this-&gt;getSetting('access_path'); //https://getpocket.com/v3/oauth/authorize
    $requirements['code']   = $code;
    $requirements['key']    = $this-&gt;getSetting('consumer_key');

    $curl = $this-&gt;initCurl($url, $requirements);
    $results = curl_exec($curl);

    echo "&lt;pre&gt;";
    print_r($results);
    echo "&lt;/pre&gt;";

    curl_close($curl);

    return $results;
}

private function authorizeToken($token){
    $auth_path      =$this-&gt;getSetting('auth_path'); //https://getpocket.com/auth/authorize?
    $redirect_path  =$this-&gt;getSetting('callback_path');
    $actionUrl = UrlHelper::getActionUrl('pocket/callback');


    $url = $auth_path.'request_token='.$token.'&amp;redirect_uri='.$actionUrl;

    header("Location:".$url);

    return $url;
}


Controller:

public function actionCallback(){

    //call pocket server for acccess token
    if(craft()-&gt;httpSession-&gt;get('code')){
        $code   = craft()-&gt;httpSession-&gt;get('code');
    }else{
        $code   = "no code";
    }

    $access_connection = craft()-&gt;pocket-&gt;accessToken($code);
    $variables['access_token'] = $access_connection;

    $this-&gt;renderTemplate('pocket/control_panel', $variables);


}


Callback template:

{% extends "_layouts/cp" %}
{% set title = "Pocket Articles"|t %}

{% set offset = craft.request.getParam('offset') %}

{% set content %}
    {{ dump(access_token) }}
{% endset %}
The init method is automatically called whenever a service class is instantiated. Think of it as akin to a constructor.

If this is not want you want, just rename the method (to initialize, for example).