Hello,
I’m totally struggling trying to revoke an access token using the API, as described here: https://dev.twitter.com/docs/auth/application-only-auth
I have code in VB.NET that executes the query and is always returned a 403/Forbidden with the following error: {“errors”:[{“code”:99,“label”:“authenticity_token_error”,“message”:“Unable to verify your credentials”}]}
I also tried a manual request in Fiddler and I am getting the same result. Which means there must be something I don’t understand in how this is supposed to be done.
So I have the following:
- a consumer key (the unique application key)
- a consumer secret (the unique application secret)
- a user’s access token (a user that got an access token from the above application)
- a user’s access token secret (which doesn’t seem to be used anywhere in the process)
The authorization header I add to the request is a base64 encoding of the concatenation of the consumer key and consumer secret with a colon in-between, as described by the documentation.
The body of the request is access_token=xxxx where xxxx is the user access token.
I always get the same 403 error. The documentation says this errors occurs when trying to:
- Obtain or revoke a bearer token with incorrect or expired app credentials --> I know the app credentials (consumer key + consumer secret, right?) is correct and not expired, because I can query the API successfully with the same credentials
- Invalidate an incorrect or revoked bearer token --> I know the bearer token (user access token, right?) is correct, because I can query the API successfully with it.
What am I doing wrong?
Thanks!
For the record, the VB code is the following:
Dim tRequest As HttpWebRequest = HttpWebRequest.Create("https://api.twitter.com/oauth2/invalidate_token")
tRequest.Method = "POST"
tRequest.ContentType = "application/x-www-form-urlencoded"
tRequest.Headers.Add("Authorization", "Basic " & Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(Tools.Configuration.TwitterClientID & ":" & Tools.Configuration.TwitterClientSecret)))
Dim tBody As String = "access_token=" & tUser.TwitterAccessToken
Using tStreamWriter As New StreamWriter(tRequest.GetRequestStream)
tStreamWriter.Write(tBody)
tStreamWriter.Flush()
End Using
Dim tResponse = tRequest.GetResponse()