We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here. 

Forum Discussion

pankajetal's avatar
pankajetal
Explorer | Level 3
2 years ago

Need help with script and authentication

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


  • 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.

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API

Make connections with other developers

795 PostsLatest Activity: 5 days ago
192 Following

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 or Facebook.

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!