Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Oauth for YouTube : Why do I get "Undefined index: oauth_token" ( Jim S.' code )
    primarykey
    data
    text
    <p>I got a little problem with the OAuth for Google, I use the Jim Saunder Libraire for CodeIgniter (http://codeigniter.com/wiki/OAuth_for_Google) but when I came to my access_youtube function, which look like that :</p> <pre><code>public function access_youtube() { //STEP 2 // Here is the first call to load the library $params['key'] = 's390075769.onlinehome.fr'; $params['secret'] = 'iHD72YKzWmbm8VTwncht_E-d'; // We can change the signing algorithm and http method by setting the following in your params array. $params['algorithm'] = 'HMAC-SHA1'; // $params['method'] = "GET"; // We need to reload the library since we left our site beetween Step 1 &amp; 2. $this-&gt;load-&gt;library('google_oauth', $params); // We are using HMAC signing you need to specify the token_secret you got from the request step as the second parameter of this method. So $token_secret = $this-&gt;session-&gt;userdata('token_secret'); $oauth = $this-&gt;google_oauth-&gt;get_access_token(false, $token_secret); // The access method will return an array with keys of ‘oauth_token’, and ‘oauth_token_secret’ // These values are your access token and your access token secret. We should store these in our database. $this-&gt;session-&gt;set_userdata('oauth_token', $oauth['oauth_token']); $this-&gt;session-&gt;set_userdata('oauth_token_secret', $oauth['oauth_token_secret']); // Now you have an access token and can make google service requests on your users behalf redirect(site_url()); } </code></pre> <p>I got several error messages : </p> <blockquote> <p>Undefined index: oauth_token</p> <p>Undefined index: oauth_token_secret</p> </blockquote> <p>which refer to the lines $this->session->set_userdata ...</p> <p>and, after each error message I get :</p> <blockquote> <p>Message: Cannot modify header information - headers already sent by (output started at /homepages/7/d390075755/htdocs/system/core/Exceptions.php:170) Filename: libraries/Session.php Line Number: 671</p> </blockquote> <p>which, I think is linked with the previous error message.</p> <p>so I tried that in the constructor :</p> <pre><code>class Example extends CI_Controller { private $CI; public function __construct() { parent::__construct(); $this-&gt;CI =&amp; get_instance(); $this-&gt;CI-&gt;load-&gt;library('session'); $oauth = array(); $oauth['oauth_token_secret']=''; $oauth['oauth_token']=''; } </code></pre> <p>just before my function but it doesn't do anything .. and I'm affraid I'm gonna loose my session variables stock by google ... isn't it ? Do I get my tokens from google ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload