Note that there are some explanatory texts on larger screens.

plurals
  1. POAccessing the Google Api to get a file list with valid access and Refresh tokens
    primarykey
    data
    text
    <p>I am using an <a href="http://www.phpclasses.org/package/7700-PHP-Authorize-and-access-APIs-using-OAuth.html" rel="nofollow">Oauth class</a> for an app to get access to the Google drive API, I have both refresh and access tokens and now all I need to get the ball rolling is to set the parameters for the request.</p> <p>My issue is that I cannot seem to find the parameters needed to get the appropriate response, I have looked at the OAuth playground and the request sent has three headers <code>Authorization</code>, <code>Host</code> And <code>Content length</code>. </p> <p>The class that I am using should handle these headers correctly and I'm pretty sure it is doing something right in that it actually receives the <code>code</code> and <code>access/refresh tokens</code> correctly. </p> <p>When I send the request an error from Google is returned;</p> <pre><code>StdClass Object ( [error] =&gt; stdClass Object ( [errors] =&gt; Array ( [0] =&gt; stdClass Object ( [domain] =&gt; global [reason] =&gt; authError [message] =&gt; Invalid Credentials [locationType] =&gt; header [location] =&gt; Authorization ) ) [code] =&gt; 401 [message] =&gt; Invalid Credentials ) ) </code></pre> <p><br> This surely indicates invalid credentials? but if I have just recieved the "fresh" access tokens and refresh tokens this should surely be OK? here is the request I am sending (as per the OAuth classes methods). <br><br></p> <pre><code>$row = $this-&gt;docs_auth-&gt;row(); $this-&gt;client = new oauth_client_class; $this-&gt;client-&gt;server = 'Google'; $this-&gt;client-&gt;redirect_uri = 'https://localhost/p4a/applications/reflex_application/index.php'; $this-&gt;client-&gt;debug = true; $this-&gt;client-&gt;client_id = REFLEX_GOOGLE_CLIENT; $this-&gt;client-&gt;client_secret = REFLEX_GOOGLE_SECRET; $this-&gt;client-&gt;access_token = $row['access_token']; $this-&gt;client-&gt;refresh_token = $row['refresh_token']; $url = 'https://www.googleapis.com/drive/v2/files'; $Values = array( 'access_token' =&gt; $this-&gt;client-&gt;access_token, 'client_id' =&gt; $this-&gt;client-&gt;client_id, 'client_secret' =&gt; $this-&gt;client-&gt;client_secret ); /* * Request: GET https://www.googleapis.com/drive/v2/files * $values = the values sent in the request * $folder = the response returned from Google. */ $this-&gt;client-&gt;callAPI($url, 'GET', $values, array( 'FailOnAccessError' =&gt; false ), $folder); $this-&gt;field-&gt;setValue(print_r($folder, true)); </code></pre> <p>So my question is, what are the correct parameters to be sent to Google to get the folder and file list and what are the headers required for the request (I don't want to edit the class too much but have needed to already). </p> <p>Thanks for your time</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.
    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