0

I'm trying to authenticate a bot which posts on stocktwits (see API) with Python/pycurl. As I understand it, first I need to request that the application is authorized to use Stocktwits user data via oauth/authorize, which returns an authorization code. Then I need to confirm permission via oauth/token, which would send back an access token that can be used to post stocktwits.

The problem I'm running into is that after I make a post request to auth/authorize, the response returned is

Host: api.stocktwits.com
Authorization: Basic bmljay5vc2hpbm92QGdtYWlsLmNvbTp6YWRuaWsxMg==
User-Agent: PycURL/7.43.0.2 libcurl/7.60.0 OpenSSL/1.1.0h zlib/1.2.11 c- 
ares/1.14.0 WinIDN libssh2/1.8.0 nghttp2/1.32.0
Accept: */*
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue

< HTTP/1.1 100 Continue

and the program just stalls waiting. How can I handle the http 100 response?

Code for api call is below

def get_auth_token:
    auth_data = ""
    c = pycurl.Curl()
    c.setopt(c.CAINFO, self.CA_CERTS)
    c.setopt(pycurl.POST, 1)
    c.setopt(c.URL, uri_to_ouath_authorize_call)
    c.setopt(c.FOLLOWLOCATION, True)
    c.setopt(c.WRITEDATA, auth_data)
    c.setopt(c.USERPWD, 'bot_account_username:password')
Phil Dwan
  • 91
  • 1
  • 9
  • in `Authorization` header above you have your username:password base64 encoded (so basically clear text), if you forgot to modify it, I would suggest to delete this question and recreate a new one without the original values – Bertrand Martel Jul 30 '18 at 00:11

1 Answers1

1

I'm guessing you need to use POSTFIELDS or READFUNCTION to supply the post data, it doesn't look like you have anything for the request body configured. See https://curl.haxx.se/libcurl/c/CURLOPT_POST.html.

Using pycurl.POST is a common mistake, normally POSTFIELDS should be used instead.

D. SM
  • 13,584
  • 3
  • 12
  • 21