cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
The Dropbox Community is looking for feedback from you! Sign up to be a part of our customer panel here.

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
1
Ask
2
Comments

Need help with script and authentication

Need help with script and authentication

pankajetal
Explorer | Level 3

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

Re: Need help with script and authentication

Здравко
Legendary | Level 20

@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

Re: Need help with script and authentication

Здравко
Legendary | Level 20

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

Re: Need help with script and authentication

Greg-DB
Dropbox Staff
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?
Need more support?