cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need help with script and authentication

Need help with script and authentication

pankajetal
Explorer | Level 3
Go to solution

Hi- I'm working on a project when I need to download different user files from dropbox to a network share (to be consumed by some other application).

I've very limited knowledge of powershell script and authentication. I'm able to make the powershell script work using my access token but it won't work for other users.

 

I want to capture the access code generated and pass it as token but I'm getting "The given OAuth 2 access token is malformed" error. Is the below even correct? Please help. 

 

 

$token= "https://www.dropbox.com/oauth2/authorize?client_id=<my app ID>&response_type=code"
$destination = "\\serverlocation\file.extension"
$headers = @{
'Authorization' = "Bearer " + $token
'Dropbox-API-Arg' = '{"path": "/Dropboxfolder/file.extension"}'
}
Invoke-RestMethod -Method Post -Uri https://content.dropboxapi.com/2/files/download -Headers $headers -ContentType 'application/octet-stream; charset=utf-8'-OutFile $destination

1 Accepted Solution

Accepted Solutions

Здравко
Legendary | Level 20
Go to solution

@pankajetal wrote:

... I'm able to make the powershell script work using my access token but it won't work for other users.

...

$token= "https://www.dropbox.com/oauth2/authorize?client_id=<my app ID>&response_type=code"
...


Hi @pankajetal,

Since you can make you script work with access token, does the token that work for you look like the one you assigned above? 🧐😀

The above "token" is a web address where Dropbox OAuth starts. That's the place where you should redirect user to grant your application access to the data. 😉 You can take a look here for step by step exercise. There 'curl' is in use; I believe you can "translate" it for pawershell use.

Good luck.

View solution in original post

2 Replies 2

Здравко
Legendary | Level 20
Go to solution

@pankajetal wrote:

... I'm able to make the powershell script work using my access token but it won't work for other users.

...

$token= "https://www.dropbox.com/oauth2/authorize?client_id=<my app ID>&response_type=code"
...


Hi @pankajetal,

Since you can make you script work with access token, does the token that work for you look like the one you assigned above? 🧐😀

The above "token" is a web address where Dropbox OAuth starts. That's the place where you should redirect user to grant your application access to the data. 😉 You can take a look here for step by step exercise. There 'curl' is in use; I believe you can "translate" it for pawershell use.

Good luck.

Greg-DB
Dropbox Staff
Go to solution
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?