Your workflow is unique 👨💻 - tell us how you use Dropbox here.
Forum Discussion
Victor C.17
9 years agoNew member | Level 1
Getting "invalid_token './' " after copying User Token
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
4 Replies
Replies have been turned off for this discussion
- Greg-DB9 years ago
Dropbox Community Moderator
What line is producing that error? Can you add some logic and logging to check the value for the token you're sending up? Based on the error, it appears you're sending up the string './', which isn't a valid token.
- Victor C.179 years agoNew member | Level 1
The async function shows no error line.
If I set a MsgBox like: MsgBox(UserToken) it shows exactly the code I just paste in the InputBox.
I noticed that my token is 64 charactes lenght and the user token is almost 10 characters less or something like that. Do I need to add the application code or something?
- Greg-DB9 years ago
Dropbox Community Moderator
I'm not sure I understand your question. Your app should use your "app key", also known as "client ID", to get the authorization URL, and send the user there. The user then gets an "authorization code" from Dropbox, and gives it back to your app. Your app should then exchange that authorization code for the access token for that user. (The authorization code is not the same as the access token.)
I recommend following the documentation here that shows how to process this using the Dropbox .NET SDK:
https://dropbox.github.io/dropbox-sdk-dotnet/html/T_Dropbox_Api_DropboxOAuth2Helper.htm
- Victor C.179 years agoNew member | Level 1
Finally! Apparently the variable "UserToken" contained the user authorization code and not the user token. I added this line:
Dim t = Await DropboxOAuth2Helper.ProcessCodeFlowAsync(UserToken, "app_id", "app_secret")
And I got the "AccessToken" from the "t" variable.
Thanks for the help.
About Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!