Skip to content
This repository has been archived by the owner on Apr 18, 2019. It is now read-only.

Connect via token (upload file to one account) #93

Open
nicolaszanghi opened this issue Oct 22, 2014 · 2 comments
Open

Connect via token (upload file to one account) #93

nicolaszanghi opened this issue Oct 22, 2014 · 2 comments

Comments

@nicolaszanghi
Copy link

Hello Ben,

Thank you for your awesome work. It work pretty well. I manage to upload file to my account. But now i would like that all users send file to one dropbox account. For that I use the token from the dropbox App console.

But I get this error : Uncaught exception 'Dropbox\Exception' with message 'Access token not found.'

I don't understand what I'm suppose to put in oauth_token_secret.

Can you help me ?

This is my code in bootstrap.php :

    $key = 'mykey';
    $secret = 'mysecret';

    // Check whether to use HTTPS and set the callback URL
    $protocol = (!empty($_SERVER['HTTPS'])) ? 'https' : 'http';
    $callback = $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

    // Instantiate the Encrypter and storage objects
    $encrypter = new \Dropbox\OAuth\Storage\Encrypter('ARANDOMSTRING');

    // Create the storage object, passing it the Encrypter object
    $storage = new \Dropbox\OAuth\Storage\Session($encrypter);

    // connect to send to concours account
    $token = new \stdClass();
    $token->oauth_token = 'mytoken';
    $token->oauth_token_secret = null;
    $storage->set($token, 'access_token');

    // Create the consumer and API objects
    $OAuth = new \Dropbox\OAuth\Consumer\Curl($key, $secret, $storage, $callback);

Many thanks !

@gasola
Copy link

gasola commented Mar 1, 2016

Hi Nicolas,
have you resolved this issue? If yes, how?

@lonalore
Copy link

lonalore commented Mar 8, 2016

You can retrieve "token" and "secret" with using "get" method:

$token = $storage->get('access_token');
$oauth_token = $token->oauth_token;
$oauth_token_secret = $token->oauth_token_secret;

You can save these values into your database for later use.

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

3 participants