cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

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

/sharing/create_shared_link_with_settings unauthorized

/sharing/create_shared_link_with_settings unauthorized

vinke
Explorer | Level 4
Go to solution

Hello,

 

im trying to create a shared link with /sharing/create_shared_link_with_settings. Despite having the sharing.write set to my App, i get unauthorized all the time.

 

What am i missing here?

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

@vinke Please print out the response body, as it should contain a more useful error message.

 

While access tokens can be used to access multiple different endpoints, different endpoints do require different scopes, so it's possible that an access token can access one endpoint but not another.

 

Also, be aware that just adding a scope to your app via the App Console does not retroactively grant that scope to existing access tokens. That being the case, to make any API calls that require that scope, you'll need to get a new access token with that scope. For example, if the access token you're using was not originally created with the "sharing.write" scope, just enabling the "sharing.write" scope on the app itself will not automatically add "sharing.write" to that particular access token, so you'd need to get a new access token for that.

View solution in original post

6 Replies 6

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

Hi @vinke,

Are you certain access token in use is up to date and not expired? Once generated, its validity (without refresh) prolong to 4 hours, at most!

Greg-DB
Dropbox Staff
Go to solution

I'll be happy to help with any issues you're having with the Dropbox API, but I'll need some more information. Please reply with:

  • the name and version number of the platform and SDK/library you are using, if any
  • the steps to reproduce the issue, including relevant code snippet(s), but don't include any access or refresh token(s)
  • the full text of any error or unexpected output from the API (be sure to print out the response body)

vinke
Explorer | Level 4
Go to solution

does the access token for this endpoint differ?

I am using the generated one from the App which is working fine for the endpoint /files/search_v2 for example.
I am not using an SDK, i am using symfony (PHP) and im using the HttpClientInterface to send the request.

As said, its working for the endpoint /files/search_v2 without any problems.

Response: 

HTTP/1.1 401 Unauthorized returned for "https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings"

 

Same headers set as for /files/search_v2 which is working fine

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

@vinke wrote:

does the access token for this endpoint differ?

I am using the generated one from the App which is working fine for the endpoint /files/search_v2 for example.

...


No, the access token could be used for all regular API calls (wherever needed). Is you are using the same token? Only you know this!

 


@vinke wrote:

...
Response: 

HTTP/1.1 401 Unauthorized returned for "https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings"

...


The above is not a body!!! This is first line of the response, actually (far from the body).

 

ADD: Try the call here with the same token. You can easy get the body out from response field. 😉

Greg-DB
Dropbox Staff
Go to solution

@vinke Please print out the response body, as it should contain a more useful error message.

 

While access tokens can be used to access multiple different endpoints, different endpoints do require different scopes, so it's possible that an access token can access one endpoint but not another.

 

Also, be aware that just adding a scope to your app via the App Console does not retroactively grant that scope to existing access tokens. That being the case, to make any API calls that require that scope, you'll need to get a new access token with that scope. For example, if the access token you're using was not originally created with the "sharing.write" scope, just enabling the "sharing.write" scope on the app itself will not automatically add "sharing.write" to that particular access token, so you'd need to get a new access token for that.

vinke
Explorer | Level 4
Go to solution

thanks for the information!

I didnt know i have to refresh the token after changing/adding a scope 🙂

Need more support?
Who's talking

Top contributors to this post

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