cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We are making some updates so the Community might be down for a few hours on Monday the 11th of November. Apologies for the inconvenience and thank you for your patience. You can find out more 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: 

Access dropbox file - Authentication failed because the remote party has closed the transport stream

Access dropbox file - Authentication failed because the remote party has closed the transport stream

Lukag
Collaborator | Level 8

i'm new in this type of access.
I wrote this code but i have the error in objet to recover the list of files in dropbox.

Dim token As String
token = "sl.B6........."
Dim _command As String
_command = "https://api.dropboxapi.com/2/files/list_folder"

Dim Request As HttpWebRequest
Request = HttpWebRequest.Create(_command)

Request.Method = "GET"
Request.KeepAlive = True
Request.ContentType = "application/json"
Request.UserAgent = "Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36"
Request.AllowAutoRedirect = True
Request.Headers.Add("Authorization", "Bearer " & token)

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

Dim Response As HttpWebResponse = Request.GetResponse()

32 Replies 32

Здравко
Legendary | Level 20

Hm..🤔 Can you recall this? 🙋🤫 Oh.. that laziness... Is it so "impossible" not to jump the things over? 🧐🤣

Lukag
Collaborator | Level 8

ok i hope to use the token refrecsh that don't expire to access data. Ok i'll generate a new one. Ty 

Здравко
Legendary | Level 20

I hope you have heard about Object Oriented Programming (OOP). It's not matter of OOP language in usage! The language makes the things easier, but it's only a predispose - it doesn't make your code object oriented automatically. Actually, you can use procedure oriented programing language (for instance) and follow object orientation (and opposite) - nothing prevents it. Why am I saying this?

You can (if you want) encapsulate functionality about credentials in a type named... let's say "Credentials". This type may contain everything needed like application key, application secret, refresh token, current access token, and expiration moment of the current access token. Also the same type may has one public property letting access to valid access token that you need each time a regular API call is going to be maid. Every time that property gets accessed, the property getter may check if the current access token is still valid (with some reserve - 3~5 mins). If it is, the current access token is passed back immediately - it is just valid. If it is not (the token expiration moment has passed and the token is expired), refresh step is performed (as discussed already) in the getter. Once the refresh call succeeds, the new expiration moment is calculated (current moment plus validity period) and saved accordingly for future use (comparison) together with the just received access token. At the end, getter returns with the new valid (again) access token.

Following this rule will make you code clear and simple.

This is OOP - functionality encapsulation and reuse. 😉

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Здравко Legendary | Level 20
  • User avatar
    Lukag Collaborator | Level 8
What do Dropbox user levels mean?