randyzwitch / OAuth.jl

Pure Julia implementation of OAuth v1.0a
http://randyzwitch.com/OAuth.jl/latest/
Other
22 stars 13 forks source link

Could not authenticate error with Twitter #21

Closed hamzaelsaawy closed 6 years ago

hamzaelsaawy commented 6 years ago

My code returns a 401 HTTP.ExceptionRequest.StatusError: {"code":32,"message":"Could not authenticate you."}

Running Julia 1.0 with package status [22d8b318] OAuth v0.7.0. My tokens work using twurl and tweepy, code is:

import OAuth
endpoint = "https://api.twitter.com/1.1/users/show.json"
options = Dict("screen_name" => "twitterdev")

httpmethod = "GET"
oauth_consumer_key = "..."
oauth_consumer_secret = "..."
oauth_token = "..."
oauth_token_secret = "..."

OAuth.oauth_request_resource(endpoint, httpmethod, options, oauth_consumer_key, 
    oauth_consumer_secret, oauth_token, oauth_token_secret)

The response is:

ERROR: HTTP.ExceptionRequest.StatusError(401, HTTP.Messages.Response:
"""
HTTP/1.1 401 Unauthorized
content-length: 64
content-type: application/json; charset=utf-8
date: Sat, 20 Oct 2018 19:38:49 GMT
server: tsa_b
set-cookie: personalization_id="v1_7vUSIDnL5tNr88OLPIlFpw=="; Expires=Mon, 19 Oct 2020 19:38:49 GMT; Path=/; Domain=.twitter.com, guest_id=v1%3A154006432993982064; Expires=Mon, 19 Oct 2020 19:38:49 GMT; Path=/; Domain=.twitter.com
strict-transport-security: max-age=631138519
x-connection-hash: ff8b6f836dd6e46d4eb6c096a372b467
x-response-time: 10

{"errors":[{"code":32,"message":"Could not authenticate you."}]}""")
randyzwitch commented 6 years ago

Not sure what to tell you...the original tests of this package still pass on Julia 1.0, but I haven't paid my attention to this package (or the related Twitter.jl) in some time.

But if you're willing to dig into it, please feel free to submit a PR

hamzaelsaawy commented 6 years ago

Unfortunately the tests dont test the oauth_header and oauth_request_resource functions. Ill try and dig around, but Im pretty new to web stuff, so no promises :/

randyzwitch commented 6 years ago

It's possible that Twitter may have changed its authentication scheme, or it could be in the Julia package. I went back and re-ran the CI here for version 0.4.0 (which passed originally), but now it doesn't

https://travis-ci.org/randyzwitch/Twitter.jl/builds/317061488

I can't work on it right, but probably the best thing to do if you're really interested in solving this would be to work from one of the passing Twitter.jl builds on Travis, pin the packages, then figure out which package breaks Twitter.jl.

randyzwitch commented 6 years ago

@hamzaelsaawy I just fixed what should be the answer. If you re-run your code using the master branch, it should work (I just validated your code with my credentials).

If Twitter interests you though, it'd be great to clean up Twitter.jl.

hamzaelsaawy commented 6 years ago

That works, thanks! Ill take a look, but no promises