himura / twitter-conduit

Twitter API package for Haskell, including enumerator interfaces and Streaming API supports.
BSD 2-Clause "Simplified" License
158 stars 48 forks source link

Sample does not work #64

Closed nomeata closed 5 years ago

nomeata commented 5 years ago

I am trying to run code inspired by https://github.com/himura/twitter-conduit/blob/master/sample/simple.hs and indeed I get to enter the PIN and it fetches the credentials, but then all requests fail with Twitter telling me I am not authenticated (TwitterErrorMessage {twitterErrorCode = 32, twitterErrorMessage = "Could not authenticate you."}).

Sorry for not giving a more helpful bug report… does this work for others or is the sample out of date somehow?

nomeata commented 5 years ago

Using https://github.com/twitter/twurl it seems that the problem is not speicific to my app or consumer API key…

nomeata commented 5 years ago

This seems to fix it:

    Credential cred <- authorize tokens getPIN mgr
    let cred' = filter (\(k,v) -> k /= "user_id" && k /= "screen_name") cred
    return $ setCredential tokens (Credential cred') def

It looks OA.getAccessToken return extra fields in the resulting credentials that should not be used in requests.

nomeata commented 5 years ago

Also reported at https://github.com/yesodweb/authenticate/issues/49

cdupont commented 5 years ago

Unfortunately, the repo seems a bit stale (see other opened issues). @himura, do you need help maintaining it?

himura commented 5 years ago

Sorry for my late reply. Thank you for reporting. I've fixed this issue in https://github.com/himura/twitter-conduit/commit/f2c632055c542cc1bc332aff660221bd7c2d75ef.