[twitter-dev] Re: Oauth timeout at access_token request

2010-12-23 Thread Dave McCall
Just in case this ever comes up for someone else, here's how I solved
this.  I had to post an empty string to the page.  If you note the
lines:

If RequestMethod = POST And Not IsNothing(Data) Then
  objRequest.ContentLength = Data.Length
  Dim objWriter As New StreamWriter(objRequest.GetRequestStream)
  objWriter.Write(Data.ToString)
  objWriter.Close()
End If

I was sending Nothing in the Data, so it was not writing to the
request stream.  When I changed that and started writing an empty
string in the request stream I started to get the response back.

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk


[twitter-dev] Re: Oauth timeout at access_token request

2010-12-22 Thread Dave McCall
I get great performance in the request_token call.

I've racked my brain trying to come up with a way to send the same
oauth headers some other way (other than writing a php page or
something to do the same).  I'm using .Net 1.1 standard HTTPWebRequest
methods to do this.  I would expect them to detect the response
correctly.

If I can't figure some other way out of it, I'll have to try writing a
little curl request.  I'm sure there's something wrong with the way
I'm doing things, but I just can't see it.  The weird part is that if
there were something wrong with my oauth headers or signature or
something, I'd expect the page to return with an error, the timeout is
the unexpected part.

In case it helps, here's my oauth request method:

--

  Public Shared Function GenerateOauthRequest(ByVal RequestUrl As
String, ByVal RequestMethod As String, ByVal ConsumerKey As String,
ByVal ConsumerSecret As String, ByVal OauthToken As String, ByVal
OauthTokenSecret As String, Optional ByVal IncludeOauthToken As
Boolean = False, Optional ByVal Data As String = Nothing, Optional
ByVal OauthVerifier As String = , Optional ByVal OauthCallback As
String = ) As Hashtable

Dim objRequest As HttpWebRequest

Dim datNow As DateTime = Date.UtcNow
Dim lngTimestamp As Long = DateToUnixTimestamp(datNow)
Dim strNonce As String = IntegerToSerialNumber(lngTimestamp) 
GenerateToken(20)

Dim strSignatureMethod As String = HMAC-SHA1
Dim strHMACKey As String = ConsumerSecretOauthTokenSecret
Dim stbSignature As New StringBuilder
Dim strSignature As String = 

stbSignature.Append(RequestMethod)
stbSignature.Append()
stbSignature.Append(UrlEncodeRFC(RequestUrl))

Dim stbOAuthData As New StringBuilder
If RequestMethod = GET And Not IsNothing(Data) Then
  If Data.Length  0 Then
stbOAuthData.Append(Data)
stbOAuthData.Append()
  End If
End If
stbOAuthData.Append(oauth_consumer_key=)
stbOAuthData.Append(ConsumerKey)
stbOAuthData.Append(oauth_nonce=)
stbOAuthData.Append(strNonce)
stbOAuthData.Append(oauth_signature_method=)
stbOAuthData.Append(strSignatureMethod)
stbOAuthData.Append(oauth_timestamp=)
stbOAuthData.Append(lngTimestamp)
If IncludeOauthToken And Not IsNothing(OauthToken) Then
  If OauthToken.Length  0 Then
stbOAuthData.Append(oauth_token=)
stbOAuthData.Append(OauthToken)
  End If
End If
If OauthVerifier.Length  0 Then
  stbOAuthData.Append(oauth_verifier=)
  stbOAuthData.Append(OauthVerifier)
End If
stbOAuthData.Append(oauth_version=1.0)

stbSignature.Append()
stbSignature.Append(UrlEncodeRFC(stbOAuthData.ToString))

strSignature = stbSignature.ToString

Dim objHMAC As New HMACSHA1(Encoding.ASCII.GetBytes(strHMACKey))
Dim bytMessage() As Byte = Encoding.ASCII.GetBytes(strSignature)
Dim bytSignature() As Byte = objHMAC.ComputeHash(bytMessage)
strSignature = Convert.ToBase64String(bytSignature)

If RequestMethod = GET And Not IsNothing(Data) Then
  If Data.Length  0 Then RequestUrl = ?  Data
End If

objRequest = WebRequest.Create(RequestUrl)
objRequest.Timeout = 3
objRequest.Method = RequestMethod

Dim stbAuthorizationHeader As New StringBuilder
stbAuthorizationHeader.Append(OAuth realm=  RequestUrl 
)
stbAuthorizationHeader.Append(,oauth_consumer_key= 
ConsumerKey  )
stbAuthorizationHeader.Append(,oauth_nonce=  strNonce  )
stbAuthorizationHeader.Append(,oauth_signature= 
UrlEncodeRFC(strSignature)  )
stbAuthorizationHeader.Append(,oauth_signature_method= 
strSignatureMethod  )
stbAuthorizationHeader.Append(,oauth_timestamp=  lngTimestamp
 )
If IncludeOauthToken And Not IsNothing(OauthToken) Then
  If OauthToken.Length  0 Then
stbAuthorizationHeader.Append(,oauth_token= 
UrlEncodeRFC(OauthToken)  )
  End If
End If
If OauthVerifier.Length  0 Then
  stbAuthorizationHeader.Append(,oauth_verifier= 
UrlEncodeRFC(OauthVerifier)  )
End If
stbAuthorizationHeader.Append(,oauth_version=1.0)

objRequest.Headers.Add(Authorization,
stbAuthorizationHeader.ToString)

Dim hshReturn As New Hashtable
Dim objResponse As HttpWebResponse
Dim objReader As StreamReader
hshReturn.Add(success, False)
Try
  If RequestMethod = POST And Not IsNothing(Data) Then
objRequest.ContentLength = Data.Length
Dim objWriter As New StreamWriter(objRequest.GetRequestStream)
objWriter.Write(Data.ToString)
objWriter.Close()
  End If
  objResponse = objRequest.GetResponse
  If Not IsNothing(objResponse.Headers(Content-Location)) Then
hshReturn.Add(content_location, objResponse.Headers(Content-
Location))
  objReader = New StreamReader(objResponse.GetResponseStream)
  hshReturn.Add(response, objReader.ReadToEnd())
  hshReturn(success) = True
Catch objWebException As 

[twitter-dev] Re: Oauth timeout at access_token request

2010-12-21 Thread Dave McCall
FYI, I have tried the same using https://api.twitter.com as well.
Also in step 3 I have currently changed it to https://api.twitter.com/
oauth/authorize because I believe that is the more correct URL
(though authenticate does appear to work).

Any thoughts?

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk


Re: [twitter-dev] Re: Oauth timeout at access_token request

2010-12-21 Thread Taylor Singletary
Hi,

I'm glad you tried the api.twitter.com URI pattern as well -- as it's really
the correct one.

It is unusual for this method to take that long. Have you tried this
sequence outside of the code environment you're working in? Is there
anything about your coding environment that may be mis-detecting the
completion of the request? What kind of performance are you getting from
other calls?

Taylor


On Tue, Dec 21, 2010 at 8:57 AM, Dave McCall d...@dave-mccall.com wrote:

 FYI, I have tried the same using https://api.twitter.com as well.
 Also in step 3 I have currently changed it to https://api.twitter.com/
 oauth/authorize because I believe that is the more correct URL
 (though authenticate does appear to work).

 Any thoughts?

 --
 Twitter developer documentation and resources: http://dev.twitter.com/doc
 API updates via Twitter: http://twitter.com/twitterapi
 Issues/Enhancements Tracker:
 http://code.google.com/p/twitter-api/issues/list
 Change your membership to this group:
 http://groups.google.com/group/twitter-development-talk


-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk


[twitter-dev] Re: Oauth timeout?

2009-08-16 Thread Ritvvij

1. Read 
http://groups.google.com/group/twitter-development-talk/browse_thread/thread/4655448e637baa81
2. Wait

On Aug 16, 5:52 pm, benn bno...@gmail.com wrote:
 Hi guys,

 I'm still getting oauth timeout issues (on twitters side).

 Repro steps in safari 3.1:

 1. go to twitterplaces.com
 2. press 'Allow'
 3. press 'Allow'
 4. wait for eternity...

 If I restart safari, clear cookies and try again then it usually
 works. I'd sure like to have this fixed, because it's preventing my
 friends from signing in. :)

 Ben
 (i'm cloning foursquare)