Call to a member function set_userdata() on a non-object, Codeigniter OAuth2
It seems like the session library has not been loaded. Try adding this near the top of your function
$this->load->library('session');
You could also have the library autoload by adding it to your application/config/autoload.php
file