0

I need your help!

My code:

 string twitterRequestTokenUrl = "http://api.twitter.com/oauth/request_token";


HttpRequestMessage request = new HttpRequestMessage();
    string data = "oauth_consumer_key=\"" + oauth_consumer_key +
                   "\", oauth_nonce=\"" + oauth_nonce +
                   "\", oauth_signature=\"" + Uri.EscapeDataString(oauth_signature) +
                   "\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"" + oauth_timestamp +
                   "\", oauth_version=\"1.0\"";
    request.Headers.Authorization = new       System.Net.Http.Headers.AuthenticationHeaderValue("OAuth", data);
    request.RequestUri = new Uri(twitterRequestTokenUrl, UriKind.Absolute);

    request.Method = new HttpMethod("POST");    
    var response = await httpClient.SendAsync(request);

What could be the problem, I send an inquiry:

request {Method: POST, RequestUri: 'http://api.twitter.com/oauth/request_token', Version: 1.1, Content: , Headers: { Authorization: OAuth oauth_consumer_key="*******************", oauth_nonce="NjM1NjQwOTY0MzAzMjMwNjgw", oauth_signature="nIQIuJqRLP2naUxgC0cTHqFqUkc%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1428485230", oauth_version="1.0" }} System.Net.Http.HttpRequestMessage

and get the following answer:

StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { connection: close date: Wed, 08 Apr 2015 09:06:50 GMT server: tsa_b set-cookie: guest_id=v1%3A142848401049508299; Domain=.twitter.com; Path=/; Expires=Fri, 07-Apr-2017 09:06:50 UTC x-connection-hash: 407806cc38f466361aa7e9efb2a35601 x-response-time: 5 Content-Length: 16 content-type: text/plain; charset=utf-8 } SSL is required

  • 1
    Try changing your twitterRequestTokenUrl to use "https" instead of http – Awad Maharoof Apr 8 '15 at 9:46
  • THANK YOU SO MUCH !!! IT'S WORK!!! – user3588235 Apr 8 '15 at 10:10
  • You are welcome! Please accept the answer if it helped you. Cheers! – Awad Maharoof Apr 8 '15 at 10:30
0

changing

string twitterRequestTokenUrl = "http://api.twitter.com/oauth/request_token";

to

string twitterRequestTokenUrl = "https://api.twitter.com/oauth/request_token";

should solve your issue.

The reason you are seeing a status code of 403 is since "only SSL connections are allowed in Twitter API endpoints"

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.