title: Twitter HTTP Requests: 403 error
body: <p>I want to send some HTTP requests to Twitter in Python in order to create a sign in for Twitter users for my app. I am using urllib, and following this link: <a href="https://dev.twitter.com/web/sign-in/implementing" rel="nofollow noreferrer">https://dev.twitter.com/web/sign-in/implementing</a>.</p>
  
  <p>But I am unable to do this. I guess I need to authenticate before requesting a token but I don't know how to do that.</p>
  
  <p>Code:</p>
  
  <pre><code>import urllib.request
  req = urllib.request.Request("https://api.twitter.com/oauth/authenticate",
  headers={'User-Agent': 'Mozilla/5.0'})
  html = urllib.request.urlopen(req).read()   //after this statement im 
                                                getting the error
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Traceback (most recent call last):
      File "&lt;pyshell#5&gt;", line 1, in &lt;module&gt;
       html = urllib.request.urlopen(req).read()
      File "C:\Python34\lib\urllib\request.py", line 161, in urlopen
        return opener.open(url, data, timeout)
      File "C:\Python34\lib\urllib\request.py", line 469, in open
        response = meth(req, response)
      File "C:\Python34\lib\urllib\request.py", line 579, in http_response
        'http', request, response, code, msg, hdrs)
      File "C:\Python34\lib\urllib\request.py", line 507, in error
       return self._call_chain(*args)
      File "C:\Python34\lib\urllib\request.py", line 441, in _call_chain
       result = func(*args)
      File "C:\Python34\lib\urllib\request.py", line 587, in http_error_default
       raise HTTPError(req.full_url, code, msg, hdrs, fp)
      urllib.error.HTTPError: HTTP Error 403: Forbidden
  </code></pre>