cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and 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: 

Hi How i use Disable_token_access in vb ?

Hi How i use Disable_token_access in vb ?

VAR_46
Helpful | Level 6
Go to solution

i alreadt read how python use it but it confuse me how to put the header , any one know how i should put it ? 

https://api.dropboxapi.com/1/disable_access_token/?"header"
or
https://api.dropboxapi.com/1/disable_access_token?"header"

and this is the header right ?
("Authorization") = "Bearer " + storedaccestoken 

1 Accepted Solution

Accepted Solutions

VAR_46
Helpful | Level 6
Go to solution

hey i already solved it, i use some method in other web to call the URL and post the access token. but thanks for the lead greg.

 

and this is my solution, looking for similiar method likes curl - X post in vb

 

Private Sub LogoutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LogoutToolStripMenuItem.Click

        Dim wHeader As WebHeaderCollection = New WebHeaderCollection()
        Dim wProxy As IWebProxy = WebRequest.GetSystemWebProxy()
        wProxy.Credentials = System.Net.CredentialCache.DefaultCredentials

        wHeader.Clear()
        wHeader.Add("Authorization: Bearer " + storedaccesstoken)
        Dim sUrl As String = "https://api.dropboxapi.com/2/auth/token/revoke"

        Dim wRequest As HttpWebRequest = DirectCast(System.Net.HttpWebRequest.Create(sUrl), HttpWebRequest)

        wRequest.Headers = wHeader
        wRequest.Method = "POST"
        wRequest.Proxy = wProxy


        Dim wResponse As HttpWebResponse = DirectCast(wRequest.GetResponse(), HttpWebResponse)

        Dim sResponse As String = ""

        Using srRead As New StreamReader(wResponse.GetResponseStream())
            sResponse = srRead.ReadToEnd()
        End Using
        If System.IO.File.Exists(FILE_NAME) = True Then
            System.IO.File.Delete(FILE_NAME)
        End If
        Dim login As New Login
        login.Show()
        Me.Close()
    End Sub

End Class

View solution in original post

8 Replies 8

Rich
Super User II
Go to solution
Moved to the API forum.

VAR_46
Helpful | Level 6
Go to solution

hey does anyone know the answer here ?

Greg-DB
Dropbox Staff
Go to solution

When using OAuth 2 to make an API call like this, as it appears you are, you should supply the token as a "Bearer" token in the "Authorization" header. The header shouldn't go on the URL itself though, as you have.

 

For example, using OAuth 2 with API v1 to revoke the access token, it would look like this, using curl:

curl -X POST https://api.dropboxapi.com/1/disable_access_token \
    --header "Authorization: Bearer ACCESS_TOKEN_HERE"

 

Or, using OAuth 2 with API v2 to revoke the access token, it would look like this, using curl:

curl -X POST https://api.dropboxapi.com/2/auth/token/revoke \
    --header "Authorization: Bearer ACCESS_TOKEN_HERE"

API v2 is recommended over API v1 as API v1 is deprecated.

VAR_46
Helpful | Level 6
Go to solution

Hi, this my code. But, it's not working. Can you help me?

storedaccesstoken = My.Computer.FileSystem.ReadAllText(FILE_NAME)
        Dim client = New WebClient()
        client.Headers("Authorization") = "Bearer " + storedaccesstoken
        Dim disableac = client.Dispose("https://api.dropboxapi.com/2/auth/token/revoke")

Greg-DB
Dropbox Staff
Go to solution
In what way is it not working? What response are you getting?

VAR_46
Helpful | Level 6
Go to solution
Well, i change the code, and found same method as curl -X POST, now the problem is im still using API v1 token flow, when i try to disable the token, it's work but now the problem is how to unlink my app so we can get a new access token

Greg-DB
Dropbox Staff
Go to solution
I'm afraid I still don't follow. Can you share what you have so far that's giving you trouble?

For reference, API v1 supports both OAuth 1 and OAuth 2. API v2 supports only OAuth 2. You can use the same OAuth 2 access tokens across both API v1 and API v2.

VAR_46
Helpful | Level 6
Go to solution

hey i already solved it, i use some method in other web to call the URL and post the access token. but thanks for the lead greg.

 

and this is my solution, looking for similiar method likes curl - X post in vb

 

Private Sub LogoutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LogoutToolStripMenuItem.Click

        Dim wHeader As WebHeaderCollection = New WebHeaderCollection()
        Dim wProxy As IWebProxy = WebRequest.GetSystemWebProxy()
        wProxy.Credentials = System.Net.CredentialCache.DefaultCredentials

        wHeader.Clear()
        wHeader.Add("Authorization: Bearer " + storedaccesstoken)
        Dim sUrl As String = "https://api.dropboxapi.com/2/auth/token/revoke"

        Dim wRequest As HttpWebRequest = DirectCast(System.Net.HttpWebRequest.Create(sUrl), HttpWebRequest)

        wRequest.Headers = wHeader
        wRequest.Method = "POST"
        wRequest.Proxy = wProxy


        Dim wResponse As HttpWebResponse = DirectCast(wRequest.GetResponse(), HttpWebResponse)

        Dim sResponse As String = ""

        Using srRead As New StreamReader(wResponse.GetResponseStream())
            sResponse = srRead.ReadToEnd()
        End Using
        If System.IO.File.Exists(FILE_NAME) = True Then
            System.IO.File.Delete(FILE_NAME)
        End If
        Dim login As New Login
        login.Show()
        Me.Close()
    End Sub

End Class
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    VAR_46 Helpful | Level 6
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?