I'm making a program in VB.Net and I have a form to paste the user Token but when I click "Ok" an error is displayed. It says: "invalid_token './'".
This is my code:
Private Async Function GetUserData() As Task
Try
If UserToken = Nothing Then
Dim enable As New EnableDropBox
If enable.ShowDialog = Windows.Forms.DialogResult.OK Then
UserToken = enable.AccessToken
Dim dbx As New DropboxClient(UserToken)
Dim full = Await dbx.Users.GetCurrentAccountAsync()
Me.Text = Application.ProductName & " [" & full.Email & "]"
RibbonTextBox1.TextBoxText = full.Email
RibbonTextBox2.TextBoxText = Split(full.AccountType.ToString, "+")(1)
SaveSetting(Application.ProductName, "Cloud", "Dropbox", UserToken)
End If
Else
Dim dbx As New DropboxClient(UserToken)
Dim full = Await dbx.Users.GetCurrentAccountAsync()
Me.Text = Application.ProductName & " [" & full.Email & "]"
RibbonTextBox1.TextBoxText = full.Email
RibbonTextBox2.TextBoxText = Split(full.AccountType.ToString, "+")(1)
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Dropbox")
End Try
End Function
And the "EnableDropBox" form code is:
Imports Dropbox.Api
Public Class EnableDropBox
Public Property AccessToken As String = Nothing
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim oauth As Uri = DropboxOAuth2Helper.GetAuthorizeUri("the_app_code", False)
Process.Start(oauth.ToString)
AccessToken = InputBox("Paste the authorization code::", "Dropbox", Nothing)
If AccessToken = Nothing Then
MsgBox("Unauthorized communication with Dropbox", MsgBoxStyle.Exclamation, "Dropbox")
Me.DialogResult = Windows.Forms.DialogResult.Cancel
Else
Me.DialogResult = Windows.Forms.DialogResult.OK
End If
End Sub
End Class
Note: I have activated the app for 500 users only for testing.
Note 2: I am using the Api 3.2.1