Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Store in db? Method missing in docs #4

Closed
talkingnews opened this issue Oct 15, 2012 · 2 comments
Closed

Store in db? Method missing in docs #4

talkingnews opened this issue Oct 15, 2012 · 2 comments

Comments

@talkingnews
Copy link

Hi Jim,

Great to see you updating this library.

In your docs, you mention:

$oauth = $this->dropbox->get_access_token($this->session->userdata('token_secret')); $this->_store_in_db($oauth['oauth_token']); $this->_store_in_db($oauth['oauth_token_secret']);

Which, of course, gives me

Call to undefined method Dbox::_store_in_db()

Is this pseudocode, or have I skipped a section of the docs, or am I missing a library or a dependency or something?

My use for your library is to authenticate (once) as me, then when users upload files, then get copied to my dropbox and I get the sharing link back, so it's me authenticated, not them. Hence the db (database not dropbox) storage method.

Over at https://github.com/BenTheDesigner/Dropbox/tree/master/Dropbox/OAuth/Storage he's got a db encrypted storage method, and warns to never store tokens unencrypted.

Does your library have anything equivalent, or might it be possible to make a hybrid including some of his code? I'm slightly into "over my head" territory here so pointers would be appreciated!

@jimdoescode
Copy link
Owner

The store in db method is pseudocode to demonstrate what you might want to do with the token data. It is purely for example purposes and was not meant to be implemented. Sorry for the confusion.

In your case you will want to record the token data in a config file and recall it that way. You only need to store the token data in a database if you are authenticating with multiple users and those users have database entries.

I am closing this ticket as it's not an issue.

@talkingnews
Copy link
Author

OK, I understand. As it happens, I just found that the CMS I am using, PyroCMS, actually has a built-in encrypted field type in its ORM, so in fact it's as easy as (something along the lines of)

$entry_data = array( 'oauth_token' => $oauth['oauth_token'], 'oauth_token_secret' => $oauth['oauth_token_secret'] ); $this->streams->entries->update_entry(1, $entry_data, 'tokens', 'streams');

and retrieve with

$token = $this->streams->entries->get_entry(1, 'tokens', 'streams');

as I found about 5 minutes before you posted here. Working well now, great library, thanks again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants