Home:ALL Converter>Exception: Required option not passed: access_token

Exception: Required option not passed: access_token

Ask Time:2016-05-07T20:18:50         Author:Sachin Vairagi

Json Formatter

I am getting this error while trying to login with Google in Codeigniter only at first attempt

Fatal error: Uncaught exception 'Exception' with message ' in ..../application/libraries/OAuth2/Token/Access.php on line 44
Exception: Required option not passed: access_token in ..../application/libraries/OAuth2/Token/Access.php on line 44

enter image description here

Author:Sachin Vairagi,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/37088445/exception-required-option-not-passed-access-token
Amit Chauhan :

Try to change your access.php file and change __construct method. \n\npublic function __construct(array $options = null)\n{\n echo \"<pre>\";\n $new_options = array();\n foreach($options as $key => $value)\n {\n $new_options = json_decode($key,true);\n }\n\n if ( ! isset($new_options['access_token']))\n {\n throw new Exception('Required option not passed: access_token'.PHP_EOL.print_r($new_options, true));\n }\n\n // if ( ! isset($options['expires_in']) and ! isset($options['expires']))\n // {\n // throw new Exception('We do not know when this access_token will expire');\n // }\n\n\n $this->access_token = $new_options['access_token'];\n\n // Some providers (not many) give the uid here, so lets take it\n isset($new_options['uid']) and $this->uid = $new_options['uid'];\n\n //Vkontakte uses user_id instead of uid\n isset($new_options['user_id']) and $this->uid = $new_options['user_id'];\n\n //Mailru uses x_mailru_vid instead of uid\n isset($new_options['x_mailru_vid']) and $this->uid = $new_options['x_mailru_vid'];\n\n // We need to know when the token expires, add num. seconds to current time\n isset($new_options['expires_in']) and $this->expires = time() + ((int) $new_options['expires_in']);\n\n // Facebook is just being a spec ignoring jerk\n isset($new_options['expires']) and $this->expires = time() + ((int) $new_options['expires']);\n\n // Grab a refresh token so we can update access tokens when they expires\n isset($new_options['refresh_token']) and $this->refresh_token = $new_options['refresh_token'];\n}\n",
2017-03-29T05:52:29
Raveendra :

If you are using oauth2, goto libraries/oauth2/provider.php there is function called access, in that switch case: POST, do it what i have shown below. \n\n case 'POST':\n\n $ci = get_instance();\n\n /*$ci->load->spark('curl/1.2.1');\n\n $ci->curl\n ->create($url)\n ->post($params, array('failonerror' => false));\n\n $response = $ci->curl->execute();*/\n\n\nHappy coding",
2016-09-17T10:42:04
yy