Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
ronS1
8 years agoExplorer | Level 4
Dropbox API not returning all files
public function __construct(Dropbox $dropbox)
{
$this->api_client = $dropbox->api();
$this->content_client = $dropbox->content();
$this->access_token = session('access_to...
- 8 years agoFor the error you're getting, it looks like you aren't passing in an access token. (I.e., "Bearer" should be followed by the access token.) You'll need to see why that is. It appears you're trying to retrieve it via `session('access_token')`, which apparently isn't working.
Anyway, yes, you can programmatically get an access token for the user using the OAuth 2 app authorization flow:
https://www.dropbox.com/developers/reference/oauth-guide
The documentation for that can be found here:
https://www.dropbox.com/developers/documentation/http/documentation#authorization
By the way, the subject for your post seems to be about another issue. If you're having another problem, please feel free to open another thread with the details.
Greg-DB
Dropbox Community Moderator
8 years agoFor the error you're getting, it looks like you aren't passing in an access token. (I.e., "Bearer" should be followed by the access token.) You'll need to see why that is. It appears you're trying to retrieve it via `session('access_token')`, which apparently isn't working.
Anyway, yes, you can programmatically get an access token for the user using the OAuth 2 app authorization flow:
https://www.dropbox.com/developers/reference/oauth-guide
The documentation for that can be found here:
https://www.dropbox.com/developers/documentation/http/documentation#authorization
By the way, the subject for your post seems to be about another issue. If you're having another problem, please feel free to open another thread with the details.
Anyway, yes, you can programmatically get an access token for the user using the OAuth 2 app authorization flow:
https://www.dropbox.com/developers/reference/oauth-guide
The documentation for that can be found here:
https://www.dropbox.com/developers/documentation/http/documentation#authorization
By the way, the subject for your post seems to be about another issue. If you're having another problem, please feel free to open another thread with the details.
- ronS18 years agoExplorer | Level 4
public function login(Request $request) { if ($request->has('code')) { $data = [ 'code' => $request->input('code'), 'grant_type' => 'authorization_code', 'client_id' => env('DROPBOX_APP_KEY'), 'client_secret' => env('DROPBOX_APP_SECRET'), 'redirect_uri' => env('DROPBOX_REDIRECT_URI') ]; $response = $this->api_client->request( 'POST', '/oauth2/token', ['form_params' => $data] ); $response_body = json_decode($response->getBody()->getContents(), true); $access_token = $response_body['access_token']; //dd($access_token); //I can access the token here return redirect('dashboard'); } return redirect('/'); }public function user(){ $response = $this->adminRepo->apiClient->request('POST', '/2/users/get_current_account', [ 'headers' => [ 'Authorization' => 'Bearer ' . $this->adminRepo->accessToken ]
//error : invalid authorization value in HTTP header "Authorization": " (truncated...) ]); $user = json_decode($response->getBody(), true); $page_data = [ 'user' => $user ]; return view('admin.user', $page_data); }Hey Greg, sorry about the post subject my bad.
Could you please take a look at above two methods in which I am trying to pass the access token generated by /oauth2/token but it returns null and throws an error of bad authorization header.Is there any possible way I can retrieve this token from within my other classes.
Thank you so much for your help. It means a lot me.
- Greg-DB8 years ago
Dropbox Community Moderator
It sounds like you are able to retrieve the access token from the API, per your "I can access the token here" comment in your code, and that you're now trying to pass that string between your classes.
Unfortunately as that is more about structuring your app and passing data (in this case a string that has the access token) around your app, I'm afraid I can't offer help, as that's not about the Dropbox API itself.
A more general PHP forum may be of more help for guidance on how to pass around data like this between your classes.- ronS18 years agoExplorer | Level 4Yeah, Greg, I figured out the problem, I thank you for your help. There is one particular problem I would like to ask for your advice. As I can list all the files present in my dropbox folders how can I upload it directly to a website without downloading the file on my local machine?
I can generate the downloadable link to store it on my local machine, but as per my requirement, I need to grab a hold of the original file(binary) from Dropbox and import it.
Could you please shed some light on this is, it would be of a great help
Much appreciated. Thanks in advance
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!