cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App 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: 

Migration V1 to V2

Migration V1 to V2

JMagnat
Explorer | Level 3

Hi,

 

in V1 I simply use:

 

        Public Function write(myFile As String) As MetaData
            Dim Client As DropNetClient = New DropNetClient(Konstanten.DropboxAppKey, Konstanten.DropboxAppSecret)
Client.UseSandbox = True
            Client.GetToken()
            Process.Start(Client.BuildAuthorizeUrl())
            MessageBox.Show("Wait")
            Try
                Dim accessToken = Client.GetAccessToken()
                Dim myFilestream As FileStream = New FileStream(myFile, FileMode.Open, FileAccess.Read)
                Dim myReturn As MetaData = Client.UploadFile("/", System.IO.Path.GetFileName(myFile), myFilestream)
                myFilestream.Close()
                Return myReturn
            Catch ex As Exception
                Return Nothing
            End Try

        End Function

How can  I get the token in V2 without entering the code by the user??? 

15 Replies 15

Greg-DB
Dropbox Staff

A "static redirect URI" would just be some unchanging URL that you could rely on, as a place to send your users. You don't necessarily need to use that technique, but if you do you should only use a URI that you trust (ideally something you control) and that you sure will continue being available.

 

The example I linked to is built as a web app though, where the redirect URI would be just be a URL for the app.

 

Since it sounds like you're not building a web app, that doesn't apply here. In that case, the SimpleTest or UniversalDemo samples would be a better reference for you. Check those out to see how this can be handled in a client-side application.

JMagnat
Explorer | Level 3

Hi Greg,

 

I add a webbrowser control to my app and now I can add files to ther dropbox. Thanx for the help.

 

I use

 

Dim myReturn As Files.FileMetadata = Await bindDropbox.Client.Files.UploadAsync("/Backups/" + bindDropbox.Filename, WriteMode.Overwrite.Instance, body:=myFilestream)

My File exists in the Dropbox and Dropbox shows me realtime that I added a file.

 

But... the UploadAsync never ends and never return to my app. What could be the reason?

Greg-DB
Dropbox Staff
When using UploadAsync with Await, the call should block until the upload is complete, and then return once it is. This is working properly for me.

How are you checking this behavior? Have you stepped through your code with a debugger? You may wish to do so if you haven't already.

JMagnat
Explorer | Level 3

Of course I step through the code. I do the call to UploadAsync and my dropbox shows me that the uploaded file is arrived.

But the call is never come back to the app.

 

In the webbrowsers Navigating-event I call my write method like

                    If bindDropbox.write(bindDropbox.BackupDestination) Is Nothing Then
                        MessageBox.Show("ERROR")
                    End If

bindDropbox is a seperate class and the write method is this

        Public Shared Async Function write(myFile As String) As System.Threading.Tasks.Task(Of Files.FileMetadata)
            Try

                Dim myReturn As Files.FileMetadata = Await bindDropbox.Client.Files.UploadAsync("/Backups/" + bindDropbox.Filename, WriteMode.Overwrite.Instance, body:=New MemoryStream(File.ReadAllBytes(myFile)))

                Return myReturn
            Catch ex As Exception
                Return Nothing
            End Try

        End Function

I have really no idea why UploadAsync isnt coming back.

Greg-DB
Dropbox Staff
I unfortunately can't seem to reproduce this behavior. Can you share a small sample project that reproduces this? Thanks in advance!

JMagnat
Explorer | Level 3

I built a demo version and... I solved it. :grinning:

 

I blocked the task with another running task in it.

 

Now it works. Thanks for the help.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    JMagnat Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?