0

I have created project in which I want file upload on my Dropbox account. It upload successfully in my Dropbox account. But problem is it will ask for authentication. I do not want that authentication popup. Bypass that authentication using my app_key and secret.

public function request_dropbox()
    {
        $params['key'] = $this->config->item("dropbox_key");
        $params['secret'] = $this->config->item("dropbox_secret");

        $this->load->library('dropbox', $params);
        $data = $this->dropbox->get_request_token(site_url("testdropbox/access_dropbox"));
        $this->session->set_userdata('token_secret', $data['token_secret']);
        redirect($data['redirect']);
    }

public function access_dropbox()
    {
        $params['key'] = $this->config->item("dropbox_key");
        $params['secret'] = $this->config->item("dropbox_secret");

        $this->load->library('dropbox', $params);

        $oauth = $this->dropbox->get_access_token($this->session->userdata('token_secret'));

        $this->session->set_userdata('oauth_token', $oauth['oauth_token']);
        $this->session->set_userdata('oauth_token_secret', $oauth['oauth_token_secret']);
        redirect('testdropbox/test_dropbox');
    }

public function test_dropbox()
    {
        $params['key'] = $this->config->item("dropbox_key");
        $params['secret'] = $this->config->item("dropbox_secret");
        $params['access'] = array('oauth_token'=>urlencode($this->session->userdata('oauth_token')),
                                  'oauth_token_secret'=>urlencode($this->session->userdata('oauth_token_secret')));

        $this->load->library('dropbox', $params);

        $dbobj = $this->dropbox->account();
        $dbpath = "Test/ABC";
        $filepath = $_SERVER['DOCUMENT_ROOT'].'/DropPHP-master/Desert.jpg';

        $this->dropbox->add($dbpath, $filepath, array('dropbox'));
        print_r($dbobj);
    }

enter image description here

I do not want above popup. How can I do that.

Greg
  • 16,359
  • 2
  • 34
  • 44
Sadikhasan
  • 18,365
  • 21
  • 80
  • 122

1 Answers1

0

The app key and secret only identify your app, and don't enable access to any Dropbox account.

To access a Dropbox account, you'll need an access token (the combination of oauth_token and oauth_token_secret in your code). An access token identifies a particular app-user pair, and enables access to that account to the extent allowed by the app's permission.

If you only want to access your own account though, you can process that app authorization once and store and re-use the resulting access token for future calls.

Greg
  • 16,359
  • 2
  • 34
  • 44