Hello,
We have been using the Twitter OAuth2 process for months and all of sudden we are getting the “403 Forbidden” error. We are getting this on several Consumer Keys.
Here is the code we are using (which has been working fine for months)
var authHeaderFormat = “Basic {0}”;
var authHeader = string.Format(authHeaderFormat,
Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}",
Uri.EscapeDataString(oAuthConsumerKey), Uri.EscapeDataString((oAuthConsumerSecret))))));
var postBody = “grant_type=client_credentials”;
HttpWebRequest authRequest = (HttpWebRequest)WebRequest.Create(oAuthUrl);
authRequest.Headers.Add(“Authorization”, authHeader);
authRequest.Method = “POST”;
authRequest.ContentType = “application/x-www-form-urlencoded;charset=UTF-8”;
authRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
using (System.IO.Stream stream = authRequest.GetRequestStream())
{
byte[] content = ASCIIEncoding.ASCII.GetBytes(postBody);
stream.Write(content, 0, content.Length);
}
authRequest.Headers.Add(“Accept-Encoding”, “gzip”);
WebResponse authResponse = authRequest.GetResponse();
NOTES
- We are not posting any with this code. We are only reading in timelines.
- We are receiving the 403 error on several accounts on both our Production and Dev sites (which has very little, if any traffic) so I doubt it’s a rate limit issue.
Any help would be great as this is affecting our production sites!