Code 89/Token Expired when using OAuth library with Classic ASP


#1

Hello all,

I am using the classic ASP OAuth library by Scott DeSapio (http://scottdesapio.com/VBScriptOAuth/) and I’m running in to a code 89/expired token problem. What I’m trying to do is post some text to my twitter account after posting it to my website. To do this, I’m calling on twitter to get the token and token_secret and then trying to use that immediately afterwards to post my status, but it keeps telling me everything is expired. I know I’m getting both token and token_secret returned, but other than that I’m not sure why they would be expired. Can anyone guide me to what I’m doing wrong?

				Dim objOAuthReceive : Set objOAuthReceive = New cLibOAuth
				
				objOAuthReceive.ConsumerKey = twitter_consumer_key
				objOAuthReceive.ConsumerSecret = twitter_consumer_secret
				objOAuthReceive.EndPoint = TWITTER_OAUTH_URL_REQUEST_TOKEN
				objOAuthReceive.Host = "api.twitter.com"
				objOAuthReceive.RequestMethod = OAUTH_REQUEST_METHOD_GET
				objOAuthReceive.TimeoutURL = OAUTH_EXAMPLE_TIMEOUT_URL
				objOAuthReceive.UserAgent = "Alert System Updater"
				
				objOAuthReceive.Send()
				
				Dim strRequestToken : strRequestToken = objOAuthReceive.Get_ResponseValue(OAUTH_TOKEN)
				Dim strRequestTokenSecret : strRequestTokenSecret = objOAuthReceive.Get_ResponseValue(oauth_token_secret)
				Set objOAuthReceive = Nothing
				
				Dim objOAuthSend : Set objOAuthSend = New cLibOAuth
				
				objOAuthSend.ConsumerKey = twitter_consumer_key
				objOAuthSend.ConsumerSecret = twitter_consumer_secret
				objOAuthSend.EndPoint = "https://api.twitter.com/1.1/statuses/update.json"
				objOAuthSend.Host = "api.twitter.com" ' required for twitter apps
				objOAuthSend.RequestMethod = "POST"
				objOAuthSend.UserAgent = "Alert System Updater" ' required for twitter apps

				objOAuthSend.Parameters.Add "oauth_token", strRequestToken
				objOAuthSend.Parameters.Add "oauth_token_secret", strRequestTokenSecret
				objOAuthSend.Parameters.Add "status", tstatus

				objOAuthSend.Send()

				Dim strResponseText : strResponseText = objOAuthSend.ResponseText
				Dim strErrorCode : strErrorCode = objOAuthSend.ErrorCode
				
				If Not IsNull(strErrorCode) Then
					Response.Status = RESPONSE_STATUS_500
					Response.Write strErrorCode
				Else
					Response.ContentType = "text/html"
					Response.CharSet = "utf-8"
					Response.Write strResponseText
				End If
				
				Set objOAuthSend = Nothing

#2

Sorry to do this, but I’m bumping this post because I’m still looking for an answer.


#3

Hi John,

The trusty old open source library ASPTwitter was recently updated to support Twitter API 1.1 with OAuth etc. This has the code you need and a working demo, in case it helps:

http://www.timacheson.com/Blog/2013/jun/asptwitter

I used ASPTwitter today and it works nicely with the current API. :slight_smile:


#4

Hi John, see my reply below. :slight_smile:


#5

Thanks Tim, it’s much appreciated.


#6

My pleasure – if there’s anything I can do to help, let me know. If you add any new API endpoints to my ASPTwitter library, e.g. to post tweets, feel free to send me the code and I’ll update the Zip file so others can use it.