ChimeraCoder / anaconda

A Go client library for the Twitter 1.1 API
MIT License
1.14k stars 247 forks source link

"Could not authenticate you." #96

Closed ghost closed 6 years ago

ghost commented 9 years ago

I can authenticate w/ mrjones/oauth and store the user token/secret, but after that when trying to use anaconda for any api requests just results in the error below.

I've verified that the consumer key/secret, and user token/secret are referenced correctly, but anaconda just does not want to work for me. Am I doing something obviously wrong here?

Get https://api.twitter.com/1.1/statuses/show.json?id=634839419317456896 returned status 401, {"errors":[{"code":32,"message":"Could not authenticate you."}]}
    anaconda.SetConsumerKey(os.Getenv("TWITTER_KEY"))
    anaconda.SetConsumerSecret(os.Getenv("TWITTER_SECRET"))
    api := anaconda.NewTwitterApi(userToken, userTokenSecret)
    res, err := api.GetTweet(634839419317456896, nil)
ghost commented 9 years ago

Can confirm that making a rest api request using mrjones/oauth Consumer.Get with the same consumer key/secret + user token/secret works. Twitter accepts the authentication, and returns data.

Francesco149 commented 8 years ago

I know I'm months late, but why not just use the buit-in oauth in anaconda?


    authUrl, tmpCred, err := anaconda.AuthorizationURL("oob")
    if err != nil {
        log.Fatal(err) 
    }

    exec.Command("xdg-open", authUrl).Run()
    fmt.Printf(
        "1. Go to %s (should have opened automatically)\n"+
            "2. Authorize the application\n"+
            "3. Enter verification code: ", authUrl,
    )

    var pin string
    fmt.Scanln(&pin)

    cred, _, err := anaconda.GetCredentials(tmpCred, pin)
    if err != nil {
        log.Fatal(err) 
    }

    api = anaconda.NewTwitterApi(cred.Token, cred.Secret)
    api.SetLogger(anaconda.BasicLogger)

    res, err := api.GetTweet(634839419317456896, nil)
    if err != nil { 
        log.Fatal(err) 
    }
muesli commented 6 years ago

Looks like this wasn't an issue with anaconda then? Closing this issue, but feel free to comment if you still need clarification. Thanks!