PHP Classes

Support for Drpbox

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement a PH...  >  All threads  >  Support for Drpbox  >  (Un) Subscribe thread alerts  
Subject:Support for Drpbox
Summary:How to get access_token after authorized token is received
Messages:17
Author:Jacques Joubert
Date:2016-11-04 12:11:35
 
  1 - 10   11 - 17  

  1. Support for Drpbox   Reply   Report abuse  
Picture of Jacques Joubert Jacques Joubert - 2016-11-04 12:11:35
Please help me with some use advice on how to get the access token after the authorized token is returned.

The auth token is stored in the database, how do I use that token with the class to get an access token.

TIA

  2. Re: Support for Drpbox   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-11-04 21:56:12 - In reply to message 1 from Jacques Joubert
There is a subclass that you can use to store and retrieve tokens automatically from a database.

You can also take the access_token variable and store it in a database, but you may have to store more values and update the database over time because the tokens may need to be refreshed when they expire.

Check this article about offline access to APIs using tokens stored in a database. The example is with Google API but you can adapt it for DropBox. Just let me know if you have difficulties.

phpclasses.org/blog/package/7700/po ...

  3. Re: Support for Drpbox   Reply   Report abuse  
Picture of Jacques Joubert Jacques Joubert - 2016-11-05 21:05:09 - In reply to message 2 from Manuel Lemos
Thank you for this info. Much appreciated. It does provide a lot of info on the way forward and after reading over it briefly I realized that what I am asking for is using the api with offline access.

I already completed the auth and received a token which was stored in my apps database, so all I needed now was understanding how to use that stored token later to access and retrieve info later.

Will get in touch if I run into difficulty.

Regards
Jacques

  4. Re: Support for Drpbox   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-11-05 21:33:47 - In reply to message 3 from Jacques Joubert
If you used the sub-class that uses the database, it will retrieve the token automatically.

  5. Re: Support for Drpbox   Reply   Report abuse  
Picture of Jacques Joubert Jacques Joubert - 2016-11-06 18:20:31 - In reply to message 4 from Manuel Lemos
I am somewhere calling the API wrong:


$success = $connection->CallAPI('https://api.dropboxapi.com/1/account/info', 'POST', null, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);


which outputs:

object(stdClass)#196 (2) {
["error_description"]=>
string(44) "No auth function available for given request"
["error"]=>
string(15) "invalid_request"
}

any suggestions on how to get user info for API ver1?

  6. Re: Support for Drpbox   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-11-07 01:01:40 - In reply to message 5 from Jacques Joubert
Well first as you may know, DropBox API v1 is deprecated now.

Another detail is that if you want to get the user information, the method is GET not POST.

  7. Re: Support for Drpbox   Reply   Report abuse  
Picture of Jacques Joubert Jacques Joubert - 2016-11-07 12:52:38 - In reply to message 6 from Manuel Lemos
Yes I am aware that DropBox API v1 is deprecated. It still works, for now.

The problem is that the new Dropbox api requires the redirect url to go to a ssl. so for a non-ssl that won't work anymore.

The only option is to go to the auth url and then copy the auth code. Doing it this way I get stuck on how to use the code to complete the process.

  8. Re: Support for Drpbox   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-11-07 19:25:45 - In reply to message 7 from Jacques Joubert
I see. Anyway, I think you just need to fix the CallAPI to use GET instead of POST to make it work.

  9. Re: Support for Drpbox   Reply   Report abuse  
Picture of Jacques Joubert Jacques Joubert - 2016-11-08 09:50:27 - In reply to message 8 from Manuel Lemos
Got DropBox API v1 to work, but get the following with v2:

it was not possible to access the API call: it was returned an unexpected response status 400 Response: Error in call to API function "users/get_current_account": Must provide HTTP header "Authorization" or URL parameter "authorization".


Anu ideas?

  10. Re: Support for Drpbox   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-11-09 01:29:38 - In reply to message 9 from Jacques Joubert
I tried that call with the example script and it works. How are you making the call?

 
  1 - 10   11 - 17