ERROR: AT + req.GetResponse() {“The remote server returned an error: (401) Unauthorized.”} System.Net.WebException
Not sure why you are quoting Twitter4J Should I have started a new Thread?.. I am using native http. please see code.
'------------------------------- FIRST TRY
Dim request As HttpWebRequest = CType(WebRequest.Create(resource_url), HttpWebRequest)
request.Headers.Add("Authorization", authHeader)
request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
Using stream As Stream = request.GetRequestStream()
Dim content() As Byte = ASCIIEncoding.ASCII.GetBytes(postBody)
stream.Write(content, 0, content.Length)
End Using
Dim response As WebResponse = request.GetResponse() '<<<<<<<<<,The remote server returned an error: (401) Unauthorized.
''=============================== SECOND TRY
Dim req As WebRequest
Dim res As HttpWebResponse
req = WebRequest.Create(resource_url)
req.Timeout = -1
req.Headers.Add("Authorization", authHeader)
res = DirectCast(req.GetResponse(), HttpWebResponse)
Dim streamReader As StreamReader
Dim strLine As String
Dim encode As Encoding = System.Text.Encoding.GetEncoding("utf-8")
streamReader = New StreamReader(res.GetResponseStream(), encode)
While True
strLine = streamReader.ReadLine()
End While
'====================================
My settings: PLEASE CHECK IF I HAVE THE CORRECT SETTINGS…THANK YOU
’ vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Here is the URL: resource_url = " https://api.twitter.com/oauth/authorize"
This is the header I am sending.
"OAuth oauth_nonce=“NjM1NTU0NDMxzzzzzMjM1MDcz”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1419864385”, oauth_consumer_key=“N3s5Q1jdVrjP2BBBB7eL7efAw”, oauth_token=“859829466-zavYyiWdI7MiQWERTGSaGiMmn2wYDz6WCVBuNQcl”, oauth_signature=“jKiLL0W6zg6pEClA%QQQQQr%2BaGHq0%3D”, oauth_version=“1.0"”
after encoding:
baseString = "POST&https%3A%2F%2Fapi.twitter.com%2Foauth%2Fauthorize&oauth_consumer_key%3DN3s5Q1jdVrjP2zKBu7eL7efAw%26oauth_nonce%3DNjM1NTU0NTQ0MTAxNDQzOTI0%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1419875610%26oauth_token%3D859829466-zavYyiWdI7MioetnmGS…
compositeKey = “UovZf9u7Zc8PgfjnSJidqRVGIWf0gUKfoqKMhr10dWbrxPLpXZ&ZicaWhq5TRVD5TQLpt67MKN4B9afMMwsRCy1MVxjlO1Ze”
oauth_signature = “2LUvMvWcYDDZ8OJSBMiceGYwCDc=”
authHeader = "OAuth oauth_nonce=“NjM1NTU0NTQ0MTAxNDQzOTI0”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1419875610”, oauth_consumer_key=“N3s5Q1jdVrjP2zKBu7eL7efAw”, oauth_token=“859829466-zavYyiWdI7MioetnmGSaGiMmn2wYDz6WCVBuNQcl”, oauth_signature="2LUvMvWcYDDZ8…
postBody = “status=Hoping%20to%20be%20authorized”
IS THIS OK? I am hoping showing these values will help you help me.
Clock is in sync.
Regenerated tokens several times.
Permissions Read/Write/Access Direct msg
Not using proxy.